Skip to content

Instantly share code, notes, and snippets.

@hirokiky
Created June 10, 2015 00:55
Show Gist options
  • Save hirokiky/18cec017374372c45639 to your computer and use it in GitHub Desktop.
Save hirokiky/18cec017374372c45639 to your computer and use it in GitHub Desktop.
Basic form of Python scripts.
"""
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