Python (Scripting) - __name__ variable
by
Jeremy Canfield |
Updated: October 28 2023
| Python (Scripting) articles
The __name__ variable is a special variable in Python that typically returns __main__. For example, let's say you have the following Python script.
#!/usr/bin/python3
print(__name__)
Running this script would print __main__ since this is the main script.
]$ python example.py
__main__
Did you find this article helpful?
If so, consider buying me a coffee over at