Skip to content

Instantly share code, notes, and snippets.

@tonygaetani
Last active January 27, 2016 09:28
Show Gist options
  • Save tonygaetani/e3a36f1cbfd23559c25c to your computer and use it in GitHub Desktop.
Save tonygaetani/e3a36f1cbfd23559c25c to your computer and use it in GitHub Desktop.
Potential argparse issue?
#!/usr/bin/env python
# mac OSX 10.10.3
# python 2.7.10 (installed with homebrew)
# argparse 1.4.0
# to test - `python argparseissue.py --help`
# expected -
# usage: issue.py [-h] -f FOO [-b BAR]
#
# This is an attempt to replicate an issue with argparse
#
# required arguments:
# -f FOO, --foo FOO this argument is REQUIRED!!!
# optional arguments:
# -h, --help show this help message and exit
# -b BAR, --bar BAR this argument is optional
#
# I hope somebody fixes it!
# actual -
# usage: issue.py [-h] -f FOO [-b BAR]
#
# This is an attempt to replicate an issue with argparse
#
# optional arguments:
# -h, --help show this help message and exit
# -f FOO, --foo FOO this argument is REQUIRED!!!
# -b BAR, --bar BAR this argument is optional
#
# I hope somebody fixes it!
from argparse import ArgumentParser
parser = ArgumentParser(description='This is an attempt to replicate an issue with argparse',
epilog='I hope somebody fixes it!')
parser.add_argument('-f', '--foo', required=True, help='this argument is REQUIRED!!!')
parser.add_argument('-b', '--bar', help='this argument is optional')
parser.parse_args()
@tonygaetani
Copy link
Author

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