# Run the hello game:
python hello_game.py
# Run the hello and bye game:
python hello_and_bye_game.py
Last active
October 26, 2015 16:19
-
-
Save gonzalo-bulnes/5c201411abba15442f25 to your computer and use it in GitHub Desktop.
Example of modularization with Python packages.
This file contains hidden or 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
__all__ = ["game"] |
This file contains hidden or 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 hello_game import say_hello | |
def say_good_bye(): | |
print 'Good Bye!' | |
# say hello | |
say_hello() | |
# say good bye | |
say_good_bye() |
This file contains hidden or 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 "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