What does __name__ do? I have only seen it paired with __main__ and nothing else.
__name__
__main__
I know that the classic if __name__ == __main__:
if __name__ == __main__:
__name__ is "__main__" if you're executing the script directly. If you're importing a module, __name__ is the name of the module.
"__main__"
foo.py:
print(__name__)
bar.py
import foo
Run the scripts:
$ python foo.py __main__ $ python bar.py foo