zenlotus / argparse

Automatically exported from code.google.com/p/argparse
Other
0 stars 0 forks source link

Handling arguments after -- #76

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
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

Original issue reported on code.google.com by iElect...@gmail.com on 24 Jun 2010 at 2:13

GoogleCodeExporter commented 9 years ago
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

Original comment by steven.b...@gmail.com on 24 Jun 2010 at 7:38

GoogleCodeExporter commented 9 years ago
Done http://bugs.python.org/issue9077

Original comment by iElect...@gmail.com on 24 Jun 2010 at 11:35

GoogleCodeExporter commented 9 years ago
Moved to bugs.python.org.

Original comment by steven.b...@gmail.com on 23 Jul 2010 at 2:28