__name__
Dunder AttributePython 2.0+Beginner
The name of a module; equals '__main__' when run as a script
Quick Info
- Documentation
- Official Docs
- Python Version
- 2.0+
Learn by Difficulty
Quick Example
python
# __name__ holds the name of a module or class print(__name__) class MyClass: pass print(MyClass.__name__) def my_func(): pass print(my_func.__name__)
__name__ is a special attribute that the name of a module; equals '__main__' when run as a script.
Try in PlaygroundTags
oopintrospectioncore