[issue15112] argparse: nargs='*' positional argument doesn't accept any items if preceded by an option and another positional

Walter Mundt report at bugs.python.org
Wed Jun 20 06:15:47 CEST 2012


New submission from Walter Mundt <waltermundt at codethink.info>:

Test case:

    from argparse import *

    parser = ArgumentParser()
    parser.add_argument('-x', action='store_true')
    parser.add_argument('y')
    parser.add_argument('z', nargs='*')

    print parser.parse_args('yy -x zz'.split(' '))

The result of this is that the "z" option is unfilled, and the "zz" argument is unrecognized, resulting in an error.  Changing the 'nargs' to '+' works in this case, but results in errors if the 'zz' is left off.

----------
messages: 163249
nosy: waltermundt
priority: normal
severity: normal
status: open
title: argparse: nargs='*' positional argument doesn't accept any items if preceded by an option and another positional

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


More information about the Python-bugs-list mailing list