Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions about __name__
#4
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!
Reply


Messages In This Thread
Questions about __name__ - by SheeppOSU - Jul-11-2019, 05:26 AM
RE: Questions about __name__ - by scidam - Jul-11-2019, 06:43 AM
RE: Questions about __name__ - by SheeppOSU - Jul-11-2019, 06:49 AM
RE: Questions about __name__ - by DeaD_EyE - Jul-11-2019, 12:51 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  __name__ and __main__ in functions Mark17 3 679 Oct-12-2023, 01:55 AM
Last Post: deanhystad
  question about if __name__=="__main__" aaander 6 1,303 Nov-13-2022, 09:06 PM
Last Post: deanhystad
  if __name__=='__main__' albin2005 3 2,093 Sep-07-2021, 09:21 AM
Last Post: albin2005
  Discord bot that asks questions and based on response answers or asks more questions absinthium 1 34,364 Nov-25-2017, 06:21 AM
Last Post: heiner55

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020