Jul-11-2019, 12:51 PM
if __name__ == '__main__': print('Run by interpreter') else: print('Module was imported')
Output:andre@andre-GP70-2PE:~$ python test_main.py
Run by interpreter
andre@andre-GP70-2PE:~$ ipython
Python 3.7.3 (default, Apr 15 2019, 14:17:18)
Type 'copyright', 'credits' or 'license' for more information
IPython 7.5.0 -- An enhanced Interactive Python. Type '?' for help.
In [1]: import test_main
Module was imported
In [2]:
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
All humans together. We don't need politicians!