Issue 76 in argparse: Handling arguments after --

4 views
Skip to first unread message

argp...@googlecode.com

unread,
Jun 24, 2010, 10:13:54 AM6/24/10
to argpar...@googlegroups.com
Status: New
Owner: ----
Labels: Type-Defect Priority-Medium

New issue 76 by iElect...@gmail.com: Handling arguments after --
http://code.google.com/p/argparse/issues/detail?id=76

optparse stopped parsing arguments after --, how can the same be achieved
with argparse?


For example:

commmand -v -- --option

I want argparse handle arguments only until --. The rest should be left
unparsed, ready to pass in subprocess


argp...@googlecode.com

unread,
Jun 24, 2010, 3:38:57 PM6/24/10
to argpar...@googlegroups.com

Comment #1 on issue 76 by steven.bethard: Handling arguments after --
http://code.google.com/p/argparse/issues/detail?id=76

Seems like you've uncovered a bug. It does handle "--" correctly, unless
you don't have any positional arguments. Can you please file this bug on
the Python tracker (bugs.python.org)? All future work on argparse will
occur in the Python trunk, not here.

Sample code:

>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('-v', action='store_true')
>>> parser.add_argument('foo')
>>> parser.parse_args(['-v', '--', '--foo'])
Namespace(foo='--foo', v=True)

>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('-v', action='store_true')
>>> parser.parse_args(['--', '-f'])
usage: [-h] [-v]
: error: unrecognized arguments: -- -f

argp...@googlecode.com

unread,
Jun 24, 2010, 7:36:17 PM6/24/10
to argpar...@googlegroups.com

argp...@googlecode.com

unread,
Jul 23, 2010, 10:36:04 AM7/23/10
to argpar...@googlegroups.com
Updates:
Status: Duplicate

Comment #3 on issue 76 by steven.bethard: Handling arguments after --
http://code.google.com/p/argparse/issues/detail?id=76

Moved to bugs.python.org.

Reply all
Reply to author
Forward
0 new messages