Skip to content

Instantly share code, notes, and snippets.

@lukecampbell
Created February 11, 2015 21:48
Show Gist options
  • Save lukecampbell/794e410568bb42deba88 to your computer and use it in GitHub Desktop.
Save lukecampbell/794e410568bb42deba88 to your computer and use it in GitHub Desktop.
example python
#!/usr/bin/env python
'''
mymodule.py
what the module does
'''
import sys
import argparse
def run_me():
print "I do stuff"
def main(args):
'''
This program does stuff
'''
if args.run_me:
run_me()
return 0 #no problems
if __name__ == '__main__':
parser = argparse.ArgumentParser(description=main.__doc__) # Now my program has the same description as the doc string of main, handy!
parser.add_argument('-r', '--run-me', action='store_true')
args = parser.parse_args()
sys.exit(main(args))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment