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

2018-06-30 Thread paul j3
paul j3 added the comment: `parse_intermixed_args` was added in v 3.7. https://docs.python.org/3/library/argparse.html#intermixed-parsing https://stackoverflow.com/questions/50916124/allow-positional-command-line-arguments-with-nargs-to-be-seperated-by-a-flag --

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

2017-12-30 Thread devurandom
Change by devurandom : -- nosy: +devurandom ___ Python tracker ___ ___ Python-bugs-list

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

2016-04-03 Thread Martin Panter
Martin Panter added the comment: Playing with Steven and Paul’s patches, they both seem to work well. Paul’s seems to have debug printing included, which should be removed. I confirmed both patches also seem to address the nargs="?" case (Issue 24223). At the moment I have zero knowledge of

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

2015-05-17 Thread Martin Panter
Martin Panter added the comment: Closed Issue 24223 as a duplicate. I understand the patch here also fixes the case of an --option before an optional positional argument using nargs=?; is that right? -- ___ Python tracker rep...@bugs.python.org

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

2014-09-03 Thread leonard gerard
leonard gerard added the comment: In my opinion this is a bug or it should be explicitly stated in the generated usage help string. -- nosy: +leonard.gerard ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15112

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

2014-09-03 Thread leonard gerard
leonard gerard added the comment: It seems that delaying positional argument parsing after all optional arguments are parsed would be clean and robust. My understanding is that optional arguments aren't ambiguous and should be processed first and removed from the arguments. Then the current

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

2014-09-03 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue14191 'argparse doesn't allow optionals within positionals' implements a 'parse_intermixed_args()' method, which parses all of the optionals with one pass, followed by a second pass that handles the positionals. It does this by

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

2014-06-30 Thread paul j3
paul j3 added the comment: I believe http://bugs.python.org/issue14174 with REMAINDER has its roots in the same issue - parse_args tries to process as many positionals as it can at a time, regardless of what's left in the argument strings. The fix proposed here depends on the 2nd argument

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

2013-08-28 Thread paul j3
paul j3 added the comment: These three changes end up testing for the same thing. The initial 'if' catches different test cases. 'subparsers' or 'remainder' might 'confuse' the 'O' test. The zero-width test ends up weeding out everything but the test cases added for this issue. # if we

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

2013-08-24 Thread Martin Panter
Martin Panter added the comment: I was surprised to discover that “option straddling” doesn’t work this way with nargs=*. It seems to work fine with most other kinds of positional arguments I have tried, and I imagine that this was by design rather than accident. Many Gnu CLI programs also

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

2013-08-24 Thread paul j3
Changes by paul j3 ajipa...@gmail.com: -- nosy: +paul.j3 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15112 ___ ___ Python-bugs-list mailing list

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

2013-08-24 Thread paul j3
paul j3 added the comment: I originally posted this on http://bugs.python.org/issue14191, but I think it belongs here. The patch I proposed is similar to berthard's, popping items off the end of 'args_counts'. I intend to check whether the logic is equivalent.

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

2012-12-29 Thread Chris Jerdonek
Chris Jerdonek added the comment: 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

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

2012-12-19 Thread Tim Cuthbertson
Changes by Tim Cuthbertson tim3d.j...@gmail.com: -- nosy: +gfxmonk ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15112 ___ ___ Python-bugs-list

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

2012-07-22 Thread Steven Bethard
Steven Bethard steven.beth...@gmail.com added the comment: Your patch is a good start, but it needs to handle all the related situations, e.g. nargs='?' and the possibility of having more than one zero-length argument at the end. I believe the following patch achieves this. Please test it

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

2012-06-22 Thread Tshepang Lekhonkhobe
Changes by Tshepang Lekhonkhobe tshep...@gmail.com: -- nosy: +tshepang ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15112 ___ ___

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

2012-06-22 Thread Walter Mundt
Walter Mundt waltermu...@codethink.info added the comment: Attached is a patch to fix this bug by deferring matching of nargs='*' argument against a zero-length pattern until the end of the arguments list. I believe that it ought to be maximally conservative in that it should not change the

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

2012-06-22 Thread Walter Mundt
Changes by Walter Mundt waltermu...@codethink.info: -- components: +Library (Lib) type: - behavior versions: +Python 2.7 ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15112 ___

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

2012-06-20 Thread R. David Murray
Changes by R. David Murray rdmur...@bitdance.com: -- nosy: +bethard ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue15112 ___ ___ Python-bugs-list

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

2012-06-19 Thread Walter Mundt
New submission from Walter Mundt waltermu...@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