Skip to content

Instantly share code, notes, and snippets.

@justinmoon
Created August 27, 2014 20:13
Show Gist options
  • Save justinmoon/41001a52216e7ab134ae to your computer and use it in GitHub Desktop.
Save justinmoon/41001a52216e7ab134ae to your computer and use it in GitHub Desktop.
attempt to demonstrate "if __name__ == '__main__' " pattern.
from other import name
if __name__ == '__main__':
print "main.py's __name__ is: " + __name__
print "imprt.py's __name__ is: {}".format(name)
print "when name is imported, this file is run, and this is printed, but the final print "+\
"statement isn't executed because __name__ =/= '__main__' in here!"
name = __name__
if __name__ == '__main__':
print "this isn't run!"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment