Created
June 10, 2015 00:55
-
-
Save hirokiky/18cec017374372c45639 to your computer and use it in GitHub Desktop.
Basic form of Python scripts.
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
""" | |
Usage | |
===== | |
:: | |
$ python easyscript.py 1 2 | |
3 | |
""" | |
import sys | |
def add(a, b): # Separate actual logic you want to do. | |
return a + b | |
def main(): # Make it just a function for interface. | |
a = int(sys.argv[1]) # To handle more complex options, use argparse. | |
b = int(sys.argv[2]) | |
print add(a, b) | |
if __name__ == "__main__": # Not to run this program by importing. | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment