Skip to content

Instantly share code, notes, and snippets.

@gonzalo-bulnes
Last active October 26, 2015 16:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gonzalo-bulnes/5c201411abba15442f25 to your computer and use it in GitHub Desktop.
Save gonzalo-bulnes/5c201411abba15442f25 to your computer and use it in GitHub Desktop.
Example of modularization with Python packages.
__all__ = ["game"]
# Run the hello game:
python hello_game.py

# Run the hello and bye game:
python hello_and_bye_game.py
from hello_game import say_hello
def say_good_bye():
print 'Good Bye!'
# say hello
say_hello()
# say good bye
say_good_bye()
print "The 'hello_game.py' file __name__ is:", __name__, "\n"
def say_hello():
print 'Hello!'
if __name__ == '__main__': # the file was called from the command line (not imported)
say_hello()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment