$ python manners.py
Hello World!
$ python other.py
Hello John!
Last active
March 28, 2024 13:32
-
-
Save mmcloughlin/dc8cf1b7066fb1c58a0365c42cfa71df to your computer and use it in GitHub Desktop.
Example of __name__ == '__main__' in Python
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
| def greet(who='World'): | |
| print 'Hello {who}!'.format(who=who) | |
| if __name__ == '__main__': | |
| greet('World') |
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
| import manners | |
| manners.greet('John') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment