Skip to content

Instantly share code, notes, and snippets.

@nnarain
Last active November 23, 2015 07:08
Show Gist options
  • Select an option

  • Save nnarain/feee3bb506828a3cb8be to your computer and use it in GitHub Desktop.

Select an option

Save nnarain/feee3bb506828a3cb8be to your computer and use it in GitHub Desktop.
from argparse import ArgumentParser
parser = ArgumentParser()
parser.add_argument('-S', '--mystring', help='a string')
parser.add_argument('-I', '--myint', type=int, help='an integer')
parser.add_argument('-R', '--recursive', action='store_true', help='set recursive mode')
parser.add_argument('-T', '--something-else', required=True, help='some other switch')
args = vars(parser.parse_args())
print args['mystring']
print args['myint']
print args['recursive']
@nnarain
Copy link
Copy Markdown
Author

nnarain commented Oct 24, 2015

python argparse example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment