[issue14191] argparse doesn't allow optionals within positionals

2021-01-29 Thread Tadek Kijkowski
Change by Tadek Kijkowski : -- pull_requests: +23191 pull_request: https://github.com/python/cpython/pull/24367 ___ Python tracker ___

[issue14191] argparse doesn't allow optionals within positionals

2021-01-19 Thread Tadek Kijkowski
Change by Tadek Kijkowski : -- nosy: +monkeyman79 nosy_count: 9.0 -> 10.0 pull_requests: +23084 pull_request: https://github.com/python/cpython/pull/24259 ___ Python tracker

[issue14191] argparse doesn't allow optionals within positionals

2017-09-06 Thread R. David Murray
R. David Murray added the comment: Thanks Paul. By the way, if you want your "real name" in What's New, just let me know what it is and I'll make the change. -- resolution: -> fixed stage: patch review -> resolved status: open -> closed ___ Python

[issue14191] argparse doesn't allow optionals within positionals

2017-09-06 Thread R. David Murray
R. David Murray added the comment: New changeset 0f6b9d230674da784ca79a0cf1a03d2af5a8b6a8 by R. David Murray in branch 'master': bpo-14191 Add parse_intermixed_args. (#3319) https://github.com/python/cpython/commit/0f6b9d230674da784ca79a0cf1a03d2af5a8b6a8 --

[issue14191] argparse doesn't allow optionals within positionals

2017-09-05 Thread R. David Murray
R. David Murray added the comment: I got an offline agreement from Zach Ware, and nobody here at the sprint has objected (though I don't know if anyone else looked), so I'll go ahead and finish the PR. -- ___ Python tracker

[issue14191] argparse doesn't allow optionals within positionals

2017-09-04 Thread Glenn Linderman
Glenn Linderman added the comment: I would dearly love to discard my private copies of argparse subclasses to implement this that I have been using for the last 5 years. Please, some other committer, concur here! -- ___ Python tracker

[issue14191] argparse doesn't allow optionals within positionals

2017-09-04 Thread R. David Murray
R. David Murray added the comment: I've turned intermixed.patch into a PR. I tweaked the documentation so that it does not refer to the details of the implementation. I tweaked the implementation to have the 'try' start before the code that modifies the state, and did the line wrapping to

[issue14191] argparse doesn't allow optionals within positionals

2017-09-04 Thread R. David Murray
Changes by R. David Murray : -- pull_requests: +3345 ___ Python tracker ___ ___

[issue14191] argparse doesn't allow optionals within positionals

2016-06-19 Thread dg1727
Changes by dg1727 : -- nosy: +dg1727 ___ Python tracker ___ ___ Python-bugs-list mailing

[issue14191] argparse doesn't allow optionals within positionals

2014-05-02 Thread paul j3
paul j3 added the comment: I encountered a conflict when merging this patch with http://bugs.python.org/issue15112. In my first testcase, 'cmd' and 'rest' failed the 'required' test in phase one of 'intermixed'. That's because 15112 postponed parsing them (with nargs=0/suppressed). I got

[issue14191] argparse doesn't allow optionals within positionals

2013-08-24 Thread Martin Panter
Martin Panter added the comment: It sounds like this bug might cover Issue 15112, which is only concerned with options between different positional parameters. -- nosy: +vadmium ___ Python tracker rep...@bugs.python.org

[issue14191] argparse doesn't allow optionals within positionals

2013-08-24 Thread paul j3
paul j3 added the comment: Above in http://bugs.python.org/issue14191#msg187051 I proposed a patch that is quite close to bethard's patch in http://bugs.python.org/issue15112#msg166173 Both modify the same place, doing the same (pop items off arg_counts). The logic is a little different.

[issue14191] argparse doesn't allow optionals within positionals

2013-08-24 Thread paul j3
Changes by paul j3 ajipa...@gmail.com: Added file: http://bugs.python.org/file29880/mixed.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___

[issue14191] argparse doesn't allow optionals within positionals

2013-08-24 Thread paul j3
Changes by paul j3 ajipa...@gmail.com: Removed file: http://bugs.python.org/file29880/mixed.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___

[issue14191] argparse doesn't allow optionals within positionals

2013-08-20 Thread paul j3
paul j3 added the comment: It's everything I intend to add. Now I'm just waiting for a committer to act, either with suggested changes, or a merge. I'm watching more than a dozen argparse patches. -- ___ Python tracker rep...@bugs.python.org

[issue14191] argparse doesn't allow optionals within positionals

2013-08-20 Thread Glenn Linderman
Glenn Linderman added the comment: So I read over your code again, and even read the documentation this time, and it all looks good, and I know it works good because I've been using the code. I tried to send a notice through Reitveld, and maybe did, but I don't know where it went, so I'll say

[issue14191] argparse doesn't allow optionals within positionals

2013-08-16 Thread Glenn Linderman
Glenn Linderman added the comment: Paul, is this ready to merge, or are you thinking of more refinements? -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___

[issue14191] argparse doesn't allow optionals within positionals

2013-05-29 Thread paul j3
paul j3 added the comment: This is a refinement of the patch with Message188609. In parse_known_intermixed_args, the temporary capture of formatted usage has been put in a try/finally structure. Positionals are now 'deactivated' with action.nargs = SUPPRESS action.default = SUPPRESS

[issue14191] argparse doesn't allow optionals within positionals

2013-05-29 Thread Glenn Linderman
Glenn Linderman added the comment: These sound like good refinements. You've been thinking. By making the fallback happen externally, it simplifies the implementation of parse_intermixed_args, and forces the application to accept responsibility for calling it with a consistent set of

[issue14191] argparse doesn't allow optionals within positionals

2013-05-13 Thread paul j3
Changes by paul j3 ajipa...@gmail.com: Removed file: http://bugs.python.org/file29880/mixed.patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___

[issue14191] argparse doesn't allow optionals within positionals

2013-05-11 Thread Glenn Linderman
Glenn Linderman added the comment: OK, I've been running with the new code most the day, and it seems functional in my testing. I only sort of follow your discussion about the custom action class caveat, probably because I haven't used custom action classes... I tried once, but failed to

[issue14191] argparse doesn't allow optionals within positionals

2013-05-10 Thread paul j3
paul j3 added the comment: 'parse_fallback_args()' function is only in the 'test_intermixed.py' file, not the patch. It should be in the 'if __name__' section of that file, along with the modified 'exit()' method, since it is part of these testing suit, not meant to be imported.

[issue14191] argparse doesn't allow optionals within positionals

2013-05-10 Thread Glenn Linderman
Glenn Linderman added the comment: paul j3: Regarding earlier versions of these files - I do not see a way of deleting them. Click on edit, then there is an option to unlink. I don't know if they ever actually get deleted, but it clears out the clutter when looking for the latest version.

[issue14191] argparse doesn't allow optionals within positionals

2013-05-10 Thread paul j3
paul j3 added the comment: I should note one caveat: As a consequence of setting nargs to 0 for the first 'parse_know_args' step, all positional entries in the namespace get an empty list value ([]). This is produced by 'ArgumentParser._get_values'. With the builtin action classes this

[issue14191] argparse doesn't allow optionals within positionals

2013-05-07 Thread Glenn Linderman
Glenn Linderman added the comment: Paul, thanks for your continued work. I had reworked your prior patch into a subclass of Argument Parser, and tweaking the code to get parse_intermixed_args to adjust the behaviors I had reported. Now substituting exactly your more flexible new code into my

[issue14191] argparse doesn't allow optionals within positionals

2013-05-06 Thread paul j3
paul j3 added the comment: This is a revision of the test_intermixed.py that I submitted earlier. Now `parse_intermixed_args` acts like `parse_args', and calls `parse_known_intermixed_args`. Again it is form that can exercise the idea without modifying `argparse.py`. If the parser has

[issue14191] argparse doesn't allow optionals within positionals

2013-05-06 Thread paul j3
paul j3 added the comment: This is the formal patch corresponding to the `test_intermixed.py`. It includes changes to `argparse.rst`, plus tests in `test_argparse.py`. These tests are near the end, after those for `parse_known_args`. They are roughly equivalent to the examples in

[issue14191] argparse doesn't allow optionals within positionals

2013-04-23 Thread Glenn Linderman
Glenn Linderman added the comment: Very nice, Paul. I tested that with some of my applications, and some of my test cases. All of them initially failed, because you have parse_intermixed_args returning parameters like parse_known_args instead of like parse_args. Now I can understand that

[issue14191] argparse doesn't allow optionals within positionals

2013-04-23 Thread paul j3
paul j3 added the comment: Yes, http://bugs.python.org/msg166175 does use 'parse_args' in the second call. But I think things would be more flexible if we had a second function: def parse_???(self, args=None, namespace=None): args, argv = self.parse_intermixed_args(args,

[issue14191] argparse doesn't allow optionals within positionals

2013-04-23 Thread Glenn Linderman
Glenn Linderman added the comment: Yes, a second function would give more flexibility. Due to the approval in msg166175 to use the name parse_intermixed_args for the functionality described there, it would probably be best to use that name for that functionality. So then we are left naming

[issue14191] argparse doesn't allow optionals within positionals

2013-04-22 Thread paul j3
paul j3 added the comment: The attached file has a 'parse_intermixed_args()' that has the same API as 'parse_known_args()'. It follows the two parse step model args, remaining_args = optionals.parse_known_args() args, extras = positionals.parse_known_args(remaining_args, args) except

[issue14191] argparse doesn't allow optionals within positionals

2013-04-18 Thread Glenn Linderman
Glenn Linderman added the comment: Paul, your comments are interesting, but your proposed patch doesn't actually solve the problem. So here I am typing away at my command prompt, and I type in a couple optional parameters I know I'll need and start on the sequence of positional ones, and

[issue14191] argparse doesn't allow optionals within positionals

2013-04-18 Thread Glenn Linderman
Glenn Linderman added the comment: I should clarify, before someone jumps in: some particular applications do implement restrictions on order of optional and positional arguments; I'm aware of that. getopt easily supported application defined order restrictions, because it processed arguments

[issue14191] argparse doesn't allow optionals within positionals

2013-04-18 Thread paul j3
paul j3 added the comment: Glenn Take a look at http://bugs.python.org/issue15427 I took a stab at changing the documentation, including recommending parse_known_args when porting optparse uses. -- ___ Python tracker rep...@bugs.python.org

[issue14191] argparse doesn't allow optionals within positionals

2013-04-18 Thread Glenn Linderman
Glenn Linderman added the comment: Docs look good as mentioned there, for the current behavior, although it would be good to improve the behavior. Note that I have supplied a wrapper (t18a.py) (if it hasn't bit-rotted for 3.4, I'm still using 3.3) that provides the needed functionality. The

[issue14191] argparse doesn't allow optionals within positionals

2013-04-16 Thread paul j3
paul j3 added the comment: This patch permits the mixing of optionals with positionals, with the caveat that a particular positional cannot be split up. If: parser = ArgumentParser() parser.add_argument('-f','--foo') parser.add_argument('cmd') parser.add_argument('rest',

[issue14191] argparse doesn't allow optionals within positionals

2013-03-29 Thread paul j3
paul j3 added the comment: Glenn I looked at your t18a.py test case parser = ArgumentParser() parser.add_argument('--foo', dest='foo') parser.add_argument('--bar', dest='bar') parser.add_argument('foz') parser.add_argument('baz', nargs='*') and parse variations on 'a b c d

[issue14191] argparse doesn't allow optionals within positionals

2013-02-13 Thread Andrew McNabb
Changes by Andrew McNabb amcn...@mcnabbs.org: -- nosy: +amcnabb ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue14191 ___ ___ Python-bugs-list

[issue14191] argparse doesn't allow optionals within positionals

2012-07-22 Thread Steven Bethard
Steven Bethard steven.beth...@gmail.com added the comment: I created Issue 15427 for the parse_args documentation bug. So let's make this issue just about parsing intermixed arguments. Yes, if someone would like to provide a patch for this, please create a method parse_intermixed_args rather

[issue14191] argparse doesn't allow optionals within positionals

2012-07-22 Thread Glenn Linderman
Glenn Linderman v+pyt...@g.nevcal.com added the comment: So my t18a.py wraps Argparse, because the externals are documented and I could understand that. Given enough time, I might be able to understand the internals too... it is just Python... Seems like the internals separate positionals and