◐ Shell
clean mode source ↗

Message 178481 - Python tracker

Was argparse ever supposed to support inputs of the form given in the example (i.e. different positional arguments straddling optional arguments): 'yy -x zz'?

The usage string shows up as: "usage: test.py [-h] [-x] y [z [z ...]]"  The original example seems to work with the current code if given as: '-x yy zz'.

Also, substituting argparse.REMAINDER for '*' in the original example gives the following both with and without the patch:

Namespace(x=False, y='yy', z=['-x', 'zz'])

That doesn't seem consistent with straddling being supported.

Lastly, passing just '-x' gives the following error with and without the patch (z should be optional):

error: the following arguments are required: y, z