Created
August 27, 2014 20:13
-
-
Save justinmoon/41001a52216e7ab134ae to your computer and use it in GitHub Desktop.
attempt to demonstrate "if __name__ == '__main__' " pattern.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from other import name | |
if __name__ == '__main__': | |
print "main.py's __name__ is: " + __name__ | |
print "imprt.py's __name__ is: {}".format(name) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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