Created
May 18, 2013 13:27
-
-
Save Coconuthack/5604388 to your computer and use it in GitHub Desktop.
Google Python Class
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
#Python Google CLass Gist | |
#hello.py program | |
#!/usr/bin/python | |
# import modules used here -- sys is a very standard one | |
import sys | |
# Gather our code in a main() function | |
def main(): | |
print 'Hello there', sys.argv[1] | |
# Command line args are in sys.argv[1], sys.argv[2] ... | |
# sys.argv[0] is the script name itself and can be ignored | |
# Standard boilerplate to call the main() function to begin | |
# the program. | |
if __name__ == '__main__': | |
main() | |
#$ python hello.py Guido #Guido as sys.argv[1] | |
#> Hello there Guido | |
#$ ./hello.py Alice # without needing 'python' first (Unix) | |
#> Hello there Alice |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment