Created
February 11, 2015 21:48
-
-
Save lukecampbell/794e410568bb42deba88 to your computer and use it in GitHub Desktop.
example 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
#!/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