[issue18943] argparse: default args in mutually exclusive groups

2020-12-04 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: rhettinger -> ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue18943] argparse: default args in mutually exclusive groups

2019-08-30 Thread Raymond Hettinger
Change by Raymond Hettinger : -- pull_requests: -5593 ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe:

[issue18943] argparse: default args in mutually exclusive groups

2019-08-29 Thread Raymond Hettinger
Change by Raymond Hettinger : -- assignee: bethard -> rhettinger nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list

[issue18943] argparse: default args in mutually exclusive groups

2018-02-22 Thread Daniel Himmelstein
Change by Daniel Himmelstein : -- pull_requests: +5593 stage: -> patch review ___ Python tracker ___

[issue18943] argparse: default args in mutually exclusive groups

2017-12-08 Thread Vincas Dargis
Vincas Dargis added the comment: On 2017-12-06 20:28, paul j3 wrote: > The default value is used *if the flag is not provided at all.* > > "nargs='?'" provides a third option, assigning the 'const' value *if the flag > is used without an argument*. This did a "click" in my

[issue18943] argparse: default args in mutually exclusive groups

2017-12-06 Thread paul j3
paul j3 added the comment: That's not how flagged (optionals) arguments work. The default value is used if the flag is not provided at all. One of your arguments is a 'store_true'. Its default value if False, which is changed to True if the '--device-get-capabilities'

[issue18943] argparse: default args in mutually exclusive groups

2017-12-06 Thread Vincas Dargis
Vincas Dargis added the comment: On 2017-12-06 19:43, paul j3 wrote: > With one flag but not its argument, I get the error that you display. That > has nothing to do with the grouping. > > 0932:~/mypy/argdev$ python3 issue18943.py --ptz-get-status > usage: issue18943.py

[issue18943] argparse: default args in mutually exclusive groups

2017-12-06 Thread paul j3
paul j3 added the comment: Did you copy the output right? Testing your parser: Without any arguments, I get the exclusive group error - the group is required: 0930:~/mypy/argdev$ python3 issue18943.py usage: issue18943.py [-h]

[issue18943] argparse: default args in mutually exclusive groups

2017-12-06 Thread Vincas Dargis
Vincas Dargis added the comment: Any progress with this? I believe it would fix my use case: ``` import argparse import pprint parser = argparse.ArgumentParser() group = parser.add_mutually_exclusive_group(required=True) group.add_argument('--device-get-capabilities',

[issue18943] argparse: default args in mutually exclusive groups

2017-07-27 Thread paul j3
paul j3 added the comment: Another manifestation of the complications in handling '?' positionals is in http://bugs.python.org/issue28734 argparse: successive parsing wipes out nargs=? values -- ___ Python tracker

[issue18943] argparse: default args in mutually exclusive groups

2017-05-18 Thread Armin Rigo
Changes by Armin Rigo : -- nosy: -arigo ___ Python tracker ___ ___

[issue18943] argparse: default args in mutually exclusive groups

2017-05-18 Thread paul j3
paul j3 added the comment: I haven't downloaded the development distribution to this computer, so can't write formal patches at this time. -- ___ Python tracker

[issue18943] argparse: default args in mutually exclusive groups

2017-04-26 Thread Raymond Hettinger
Changes by Raymond Hettinger : -- assignee: -> bethard priority: high -> normal ___ Python tracker ___

[issue18943] argparse: default args in mutually exclusive groups

2017-04-26 Thread Louie Lu
Louie Lu added the comment: paul, will you work on this patch? or I can help this issue, too. -- nosy: +louielu type: -> behavior versions: +Python 3.7 ___ Python tracker

[issue18943] argparse: default args in mutually exclusive groups

2017-04-26 Thread paul j3
paul j3 added the comment: This came up again, http://bugs.python.org/issue30163 An optional with int type and small integer default. -- priority: normal -> high ___ Python tracker

[issue18943] argparse: default args in mutually exclusive groups

2016-11-22 Thread Wolfgang Maier
Changes by Wolfgang Maier : -- nosy: +wolma ___ Python tracker ___

[issue18943] argparse: default args in mutually exclusive groups

2014-03-03 Thread paul j3
paul j3 added the comment: I need to tweak the last patch so 'using_default' is also set when an nargs='*' positional is set to the '[]' default. if action.default is not None: value = action.default +using_default = True else:

[issue18943] argparse: default args in mutually exclusive groups

2014-02-14 Thread paul j3
paul j3 added the comment: This patch corrects the handling of `seen_non_default_action` in another case - a positional with '?' and `type=int` (or other conversion). if parser.add_argument('badger', type=int, nargs='?', default=2) # or '2' and the original test

[issue18943] argparse: default args in mutually exclusive groups

2013-09-10 Thread Armin Rigo
Armin Rigo added the comment: The patch looks good to me. It may break existing code, though, as reported on https://bugs.pypy.org/issue1595. I would say that it should only go to trunk. We can always fix PyPy (at Python 2.7) in a custom manner, in a bug-to-bug compatibility mode.

[issue18943] argparse: default args in mutually exclusive groups

2013-09-09 Thread paul j3
paul j3 added the comment: At the very least the `is not action.default` needs to be changed. Else where in argparse `is` is only used with `None` or constant like `SUPPRESS`. So using it with a user defined parameter is definitely not a good idea. Possible variations on how `is` behaves

[issue18943] argparse: default args in mutually exclusive groups

2013-09-09 Thread paul j3
paul j3 added the comment: This patch uses a narrow criteria - if `_get_values()` sets the value to `action.default`, then argument counts as 'not present'. I am setting a `using_default` flag in `_get_values`, and return it for use by `take_action`. In effect, the only change from previous

[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3
paul j3 added the comment: Changing the test from if argument_values is not action.default: to if argument_values is not action.default and \ (action.default is None or argument_values != action.default): makes the behavior more consistent. Strings and large ints behave

[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3
paul j3 added the comment: A possibly unintended consequence to this `seen_non_default_actions` testing is that default values do not qualify as 'present' when testing for a required mutually exclusive group. p=argparse.ArgumentParser() g=p.add_mutually_exclusive_group(required=True)

[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3
paul j3 added the comment: I should add that defaults with required arguments (or groups?) doesn't make much sense. Still there's nothing in the code that prevents it. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18943

[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread Armin Rigo
Armin Rigo added the comment: Fwiw I agree with you :-) I'm just relaying a bug report that originates on PyPy (https://bugs.pypy.org/issue1595). -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18943

[issue18943] argparse: default args in mutually exclusive groups

2013-09-08 Thread paul j3
paul j3 added the comment: This `argument_values` comes from `_get_values()`. Most of the time is derived from the `argument_strings`. But in a few cases it is set to `action.default`, specifically when the action is an optional postional with an empty `argument_strings`.

[issue18943] argparse: default args in mutually exclusive groups

2013-09-07 Thread Terry J. Reedy
Changes by Terry J. Reedy tjre...@udel.edu: -- nosy: +bethard ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18943 ___ ___ Python-bugs-list mailing

[issue18943] argparse: default args in mutually exclusive groups

2013-09-07 Thread Armin Rigo
Armin Rigo added the comment: Getting consistently one behavior or the other would be much better imho; I think it's wrong-ish to have the behavior depend uncontrollably on implementation details. But I agree that it's slightly messy to declare which of the two possible fixes is the right

[issue18943] argparse: default args in mutually exclusive groups

2013-09-07 Thread Antoine Pitrou
Antoine Pitrou added the comment: The patch isn't a good unittest case because it produces an Error, not a Failure. Please let's not be pedantic about what a good unittest is. -- nosy: +pitrou ___ Python tracker rep...@bugs.python.org

[issue18943] argparse: default args in mutually exclusive groups

2013-09-06 Thread Armin Rigo
New submission from Armin Rigo: In argparse, default arguments have a strange behavior that shows up in mutually exclusive groups: specifying explicitly on the command-line an argument, but giving it its default value, is sometimes equivalent to not specifying the argument at all, and

[issue18943] argparse: default args in mutually exclusive groups

2013-09-06 Thread Armin Rigo
Changes by Armin Rigo ar...@users.sourceforge.net: -- keywords: -patch ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18943 ___ ___

[issue18943] argparse: default args in mutually exclusive groups

2013-09-06 Thread Armin Rigo
Changes by Armin Rigo ar...@users.sourceforge.net: -- components: +Library (Lib) ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue18943 ___ ___

[issue18943] argparse: default args in mutually exclusive groups

2013-09-06 Thread paul j3
paul j3 added the comment: The patch isn't a good unittest case because it produces an Error, not a Failure. It does, though, raise a valid question about how a Mutually_exclusive_group tests for the use of its arguments. As you note, argparse does use the `is` test: `argument_values is not

[issue18943] argparse: default args in mutually exclusive groups

2013-09-06 Thread paul j3
paul j3 added the comment: A further complication on this. With the arguments I defined in the previous post p.parse_args('--foo test --baz 257'.split()) gives the mutually exclusive error message. `sys.argv` does the same. p.parse_args(['--foo', 'test', '--baz', '257']) does not