[issue9077] argparse does not handle arguments correctly after --

Domen Kožar report at bugs.python.org
Fri Jun 25 15:57:12 CEST 2010


Domen Kožar <ielectric at gmail.com> added the comment:

I agree — not the best example, here is a better one explaining what behavior should not exist:

>>> parser = argparse.ArgumentParser()
>>> parser.add_argument('foobar', action='store')
>>> parser.add_argument('foobar2', nargs='?')
>>> parser.add_argument('foobar3', nargs='*')
>>> print parser.parse_args(['foo', '--', 'foo3', 'foo3'])
Namespace(foobar='foo', foobar2='foo3', foobar3=['foo3'])


I would expect both foo3 to be part of foobar3. This does not happen because of foobar2 argument eating zero or one argument. Arguments after -- should be left unparsed as such behavior was in optparse.

----------

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


More information about the Python-bugs-list mailing list