[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

Clint Olsen report at bugs.python.org
Thu Sep 15 03:48:09 EDT 2016


Clint Olsen added the comment:

Thanks for the suggestion!

It seems to be extremely limited, unfortunately. I don't want option processing to cease once I hit this switch.

p=argparse.ArgumentParser()
p.add_argument('--subscipt_args', nargs='...')
#p.add_argument('pos',nargs='*')
p.add_argument('--verbose', action='store_true')

args = p.parse_args('--subscipt_args --foo --bar --baz -- --verbose '.split())

print(args)

usage: test.py [-h] [--subscipt_args ...] [--verbose]
test.py: error: unrecognized arguments: -- --verbose

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue9334>
_______________________________________


More information about the Python-bugs-list mailing list