[issue22240] argparse support for "python -m module" in help

2014-09-08 Thread paul j3
paul j3 added the comment: When I apply `prog3.diff` to my 3.5.0dev, and run python3 -m unittest Lib/test/test_argparse.py I get 2 failures, both over 'usage: python3 -m [unit]test'. It also fails with python3 test_argparse.py I suspect it would also fail if I ran the

[issue22240] argparse support for "python -m module" in help

2014-09-08 Thread paul j3
paul j3 added the comment: In argparse.py, I would put a utility function like `_prog_name` near the start in the 'Utility functions and classes' block. In test_argparse.py, I don't see the purpose of the `progname` changes in the TestParentParsers class. That class wasn

[issue22363] argparse AssertionError with add_mutually_exclusive_group and help=SUPPRESS

2014-09-08 Thread paul j3
paul j3 added the comment: This assertion has triggered several bug issues, either due to an empty group like this, or certain characters in the metavars. http://bugs.python.org/issue17890 'argparse: mutually exclusive groups full of suppressed args can cause AssertionErrors&#

[issue22240] argparse support for "python -m module" in help

2014-09-10 Thread paul j3
paul j3 added the comment: One way to reduce the testing burden, and to be extra safe regarding backward compatibility is to make this action optional, rather than the default. For example, make `_prog_name` importable (i.e. change the name), and then expect the user to use it explicitly with

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-13 Thread paul j3
New submission from paul j3: When there's a conflict involving an argument that was added via 'parents', and the conflict handler is 'resolve', the action in the parent parser may be damaged, rendering that parent unsuitable for further use. In this example, 2 parent

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-17 Thread paul j3
paul j3 added the comment: 'sample3.py' contains a '_handle_conflict_parent' function. With the help of a change in '_add_container_actions' it determines whether a conflicting action occurs in multiple parsers (and argument_groups). If it does, it deletes it f

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-18 Thread paul j3
Changes by paul j3 : Added file: http://bugs.python.org/file36648/sample3.py ___ Python tracker <http://bugs.python.org/issue22401> ___ ___ Python-bugs-list mailin

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-18 Thread paul j3
Changes by paul j3 : Removed file: http://bugs.python.org/file36635/sample3.py ___ Python tracker <http://bugs.python.org/issue22401> ___ ___ Python-bugs-list mailin

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-18 Thread paul j3
Changes by paul j3 : Added file: http://bugs.python.org/file36656/sample3.py ___ Python tracker <http://bugs.python.org/issue22401> ___ ___ Python-bugs-list mailin

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-18 Thread paul j3
Changes by paul j3 : Removed file: http://bugs.python.org/file36648/sample3.py ___ Python tracker <http://bugs.python.org/issue22401> ___ ___ Python-bugs-list mailin

[issue22433] Argparse considers unknown optional arguments with spaces as a known positional argument

2014-09-20 Thread paul j3
paul j3 added the comment: Your patch fails: python3 -m unittest test_argparse.TestEmptyAndSpaceContainingArguments specifically these 2 subcases: (['-a badger'], NS(x='-a badger', y=None)), (['-y', '-a badger'], NS(x=None, y='-a

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-20 Thread paul j3
Changes by paul j3 : -- nosy: +bethard ___ Python tracker <http://bugs.python.org/issue22401> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue22433] Argparse considers unknown optional arguments with spaces as a known positional argument

2014-09-20 Thread paul j3
Changes by paul j3 : Added file: http://bugs.python.org/file36674/example.py ___ Python tracker <http://bugs.python.org/issue22433> ___ ___ Python-bugs-list mailin

[issue22433] Argparse considers unknown optional arguments with spaces as a known positional argument

2014-09-20 Thread paul j3
Changes by paul j3 : Removed file: http://bugs.python.org/file36672/example.py ___ Python tracker <http://bugs.python.org/issue22433> ___ ___ Python-bugs-list mailin

[issue22433] Argparse considers unknown optional arguments with spaces as a known positional argument

2014-09-22 Thread paul j3
paul j3 added the comment: Proposed patches like this are supposed to be generated against the current development version (3.5...), especially if they are 'enhancements' (as opposed to bugs). But there isn't much of a difference in argparse between 2.7+ and 3.4+ (except o

[issue22433] Argparse considers unknown optional arguments with spaces as a known positional argument

2014-09-23 Thread paul j3
paul j3 added the comment: I've added a patch with tests that I think handles this case, without messing with existing test cases. It adds a new 'space' test right before the existing one, one that explicitly handles an '=' arg_string. If the space is in the 1s

[issue22500] Argparse always stores True for positional arguments

2014-09-25 Thread paul j3
paul j3 added the comment: A 'store_true' action takes 0 arguments. In effect `nargs=0`. With an `optional` (flagged) argument, the default `False` is used if the flag is absent, and set to `True` when the flag is encountered (its Action `__call__` function is run). A `posi

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-26 Thread paul j3
Changes by paul j3 : Added file: http://bugs.python.org/file36728/sample3.py ___ Python tracker <http://bugs.python.org/issue22401> ___ ___ Python-bugs-list mailin

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-09-26 Thread paul j3
Changes by paul j3 : Removed file: http://bugs.python.org/file36656/sample3.py ___ Python tracker <http://bugs.python.org/issue22401> ___ ___ Python-bugs-list mailin

[issue9350] add remove_argument_group to argparse

2014-09-28 Thread paul j3
paul j3 added the comment: If the empty argument group has a 'description' it is displayed. For example with positionals group that I mentioned earlier: parser = argparse.ArgumentParser() parser._action_groups[0].description = 'test' parser.print_help()

[issue22401] argparse: 'resolve' conflict handler damages the actions of the parent parser

2014-10-01 Thread paul j3
paul j3 added the comment: A simpler solution is to make a copy of each Action when importing a parent parser. The current practice is to just copy references. With a copy, an Action will belong to only one group and parser, and the 'resolve' handler will operate without problem

[issue19959] argparse.FileType does not expand tilde "~"

2013-12-18 Thread paul j3
paul j3 added the comment: Normally the unix shell takes care of this expansion. If I call a simple script that prints sys.argv and runs a simple parser, I get: 2135:~/mypy$ python2.7 filetypetest.py ~/mypy/test.txt ['filetypetest.py', '/home/paul/mypy/test.txt'

[issue20039] Missing documentation for argparse.ArgumentTypeError

2013-12-21 Thread paul j3
paul j3 added the comment: In argparse.py the status of ArgumentTypeError is ambiguous. ArgumentError is listed as a public class, ArgumentTypeError is not. It also says 'All other classes in this module are considered implementation details.' ArgumentTypeError is a subclass of

[issue9694] argparse required arguments displayed under "optional arguments"

2014-02-12 Thread paul j3
paul j3 added the comment: As Steven pointed out, the existing `add_argument_group` mechanism can be used to group required arguments. For example - temp.py -- parser = argparse.ArgumentParser(description = 'Do something')

[issue9694] argparse required arguments displayed under "optional arguments"

2014-02-13 Thread paul j3
paul j3 added the comment: The attached file shows how the default argument groups could be redefined, using 'required' as the criteria. I've implemented it as a method that is added to a subclass of ArgumentParser. This method is invoked after arguments are defined, prior to

[issue9694] argparse required arguments displayed under "optional arguments"

2014-02-13 Thread paul j3
paul j3 added the comment: Here's another possible solution: add a `help_groups` parameter to ArgumentParser. It is a list of base argument group names. `parser.add_argument(...)' places the action in one of those groups. This is a generalization of the current code which creates

[issue9694] argparse required arguments displayed under "optional arguments"

2014-02-13 Thread paul j3
Changes by paul j3 : Added file: http://bugs.python.org/file34074/alt_grouping2.py ___ Python tracker <http://bugs.python.org/issue9694> ___ ___ Python-bugs-list mailin

[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

[issue11588] Add "necessarily inclusive" groups to argparse

2014-02-14 Thread paul j3
paul j3 added the comment: The suggestion in this issue is to add a 'mutually_inclusive_group' mechanism, one that would let users specify that certain sets of arguments must occur together. Furthermore there was mention of allowing some sort of nesting. Modeling

[issue11588] Add "necessarily inclusive" groups to argparse

2014-02-14 Thread paul j3
paul j3 added the comment: Regarding a usage line like: (-o FILE | (-O DIR & (-p PATTERN | -s SUFFIX)) The simplest option is to just a custom written 'usage' parameter. With the existing HelpFormatter, a nested grouping like this is next to impossible. It formats the argu

[issue11588] Add "necessarily inclusive" groups to argparse

2014-02-21 Thread paul j3
paul j3 added the comment: This patch uses: tests = self._registries['cross_tests'].values() to get a list of functions to run at the end of '_parse_known_args'. I replaced all of the mutually_exclusive_group tests (3 places) in the ArgumentParser with a static funct

[issue11588] Add "necessarily inclusive" groups to argparse

2014-02-22 Thread paul j3
paul j3 added the comment: This is an example of using 'patch_w_mxg2.diff' to handle the inclusive group case proposed by the OP. Since 'seen_non_default_actions' (and 'seen_actions') is a set of 'Actions', it is convenient to use 'set' meth

[issue11588] Add "necessarily inclusive" groups to argparse

2014-02-25 Thread paul j3
paul j3 added the comment: http://stackoverflow.com/questions/11455218 python, argparse: enable input parameter when another one has been specified $ python myScript.py --parameter1 value1 $ python myScript.py --parameter1 value1 --parameter2 value2 $ python myScript.py --parameter2

[issue11588] Add "necessarily inclusive" groups to argparse

2014-02-25 Thread paul j3
paul j3 added the comment: The addition of a simple decorator to the 'ArgumentParser' class, would simplify registering the tests: def crosstest(self, func): # decorator to facilitate adding these functions name = func.__name__ self.register('cro

[issue10984] argparse add_mutually_exclusive_group should accept existing arguments to register conflicts

2014-02-28 Thread paul j3
paul j3 added the comment: In http://bugs.python.org/issue11588 (Add "necessarily inclusive" groups to argparse) I propose a generalization to these testing groups that would solve your 'conflicter' case as follows: usage = 'prog [ --conflicter | [ --opt1 ]

[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 +

[issue11588] Add "necessarily inclusive" groups to argparse

2014-03-04 Thread paul j3
paul j3 added the comment: A couple more thoughts on an expanded argument testing mechanism: - do we need both 'seen_actions' and 'seen_non_default_actions'? 'seen_actions' is used only to test whether all required actions have been seen. These 2 sets

[issue28742] argparse.ArgumentDefaultsHelpFormatter sometimes provides inaccurate documentation of defaults, so they should be overrideable

2016-11-23 Thread paul j3
paul j3 added the comment: I might accept a patch that tweaks the ArgumentDefaultsHelpFormatter class, but adding a parameter that must propagate through all the Action classes in just plain wrong. Users are confused by the many Action parameters as it is. And based on StackOverFlow

[issue27153] Default value shown by argparse.ArgumentDefaultsHelpFormatter is backwards for action='store_false'

2016-11-23 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue27153> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2016-12-10 Thread paul j3
Changes by paul j3 : -- priority: normal -> high ___ Python tracker <http://bugs.python.org/issue14156> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue25035] Getter/setter for argparse keys

2016-12-10 Thread paul j3
paul j3 added the comment: Yes, the information that `add_argument` returns a Action object is missing from the documentation. It might be useful addition. The documentation has many faults. It isn't basic enough to be a tutorial, but many first time users use it as such, and get con

[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2016-12-11 Thread paul j3
paul j3 added the comment: The problem with the argparse backlog is that the original author of the module is too busy with other things. And no one has stepped into his shoes. There are people with experience in apply patches, and people who know the argparse code well, but few, if any

[issue11874] argparse assertion failure with brackets in metavars

2016-12-12 Thread paul j3
Changes by paul j3 : -- priority: normal -> high ___ Python tracker <http://bugs.python.org/issue11874> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue14156] argparse.FileType for '-' doesn't work for a mode of 'rb'

2016-12-14 Thread paul j3
paul j3 added the comment: The problem with Python2.7 is that 'open' does not take 'closefd', or any of the other parameters that were added for Python3. open(name[, mode[, buffering]]) 'rb' may make a difference on Py2 on Windows, but I haven't done any

[issue14364] Argparse incorrectly handles '--' as argument to option

2016-12-17 Thread paul j3
paul j3 added the comment: I've copied 'dbldash.patch' over from http://bugs.python.org/issue13922. I mistakenly added it to a closed issue. The patch is old, and should be revised. It is also missing tests for this '--opt=--' case, even though it solves it. I

[issue29030] argparse: choices override metavar

2017-01-06 Thread paul j3
paul j3 added the comment: Here's the method in HelpFormatter that creates the metavar: def _metavar_formatter(self, action, default_metavar): if action.metavar is not None: result = action.metavar elif action.choices is not None: choice_strs =

[issue29030] argparse: choices override metavar

2017-01-06 Thread paul j3
paul j3 added the comment: subparsers is an example of choices displaying as the metavar. From the documentation example: usage: PROG [-h] [--foo] {a,b} ... positional arguments: {a,b} sub-command help - To the main parser, the 'subparser' is a positional argu

[issue14392] type=bool doesn't raise error in argparse.Action

2017-01-09 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue14392> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue9182] document “--” as a way to distinguish option w/ narg='+' from positional argument in argparse

2017-01-09 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue9182> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue14102] argparse: add ability to create a man page

2017-01-09 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue14102> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue9625] argparse: Problem with defaults for variable nargs when using choices

2017-01-19 Thread paul j3
Changes by paul j3 : -- priority: normal -> high ___ Python tracker <http://bugs.python.org/issue9625> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

2017-01-19 Thread paul j3
Changes by paul j3 : -- priority: normal -> high ___ Python tracker <http://bugs.python.org/issue9338> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue9625] argparse: Problem with defaults for variable nargs when using choices

2017-01-19 Thread paul j3
paul j3 added the comment: Recent StackOverFlow question related to this issue http://stackoverflow.com/questions/41750896/python-argparse-type-inconsistencies-when-combining-choices-nargs-and-def/41751730#41751730 -- ___ Python tracker <h

[issue9338] argparse optionals with nargs='?', '*' or '+' can't be followed by positionals

2017-01-19 Thread paul j3
paul j3 added the comment: Recent StackOverFlow question related to this issue - where the following positional is a subparsers. http://stackoverflow.com/questions/41742205/how-to-argparse-with-nargs-and-subcommands -- ___ Python tracker <h

[issue29298] argparse fails with required subparsers, un-named dest, and empty argv

2017-01-19 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue9253 argparse: optional subparsers Initially this bug/issue was a request to allow subparsers to be optional. But with the change in how required actions are handled, subparsers are now optional by default. As you learned from the SO

[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2017-01-24 Thread paul j3
Changes by paul j3 : -- priority: normal -> high ___ Python tracker <http://bugs.python.org/issue14074> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue14074] argparse allows nargs>1 for positional arguments but doesn't allow metavar to be a tuple

2017-01-24 Thread paul j3
paul j3 added the comment: An alternative fix is to disallow tuple metavars for positionals. A tuple metavar may look nice in the usage. But a well selected dest seems better in the help line, and error messages. Using dest in all 3 roles, as we do now, is the simplest compromise

[issue23298] Add ArgumentParser.add_mutually_dependence_group

2017-01-31 Thread paul j3
paul j3 added the comment: I propose closing this with reference to http://bugs.python.org/issue11588 -- status: open -> closed ___ Python tracker <http://bugs.python.org/issu

[issue11588] Add "necessarily inclusive" groups to argparse

2017-01-31 Thread paul j3
paul j3 added the comment: Another issue requesting a 'mutually dependent group' http://bugs.python.org/issue23298 -- ___ Python tracker <http://bugs.python.o

[issue24736] argparse add_mutually_exclusive_group do not print help

2017-01-31 Thread paul j3
paul j3 added the comment: I'm proposing closing this with reference to http://bugs.python.org/issue22047 That focuses on the issue of adding mutually exclusive group to another exclusive group, but adding Argument Group has the same problems. Solutions, short of the big

[issue22047] argparse improperly prints mutually exclusive options when they are in a group

2017-01-31 Thread paul j3
paul j3 added the comment: A similar issue about nesting an Argument Group inside a Mutually Exclusive Group. http://bugs.python.org/issue24736 -- ___ Python tracker <http://bugs.python.org/issue22

[issue29553] Argparser does not display closing parentheses in nested mutex groups

2017-02-22 Thread paul j3
paul j3 added the comment: http://bugs.python.org/issue22047 "argparse improperly prints mutually exclusive options when they are in a group" is similar. - There are two issues: - the nesting of mutually exclusive groups - the formatting of the usage in such cases. Both ha

[issue29626] Issue with spacing in argparse module while using help

2017-02-22 Thread paul j3
paul j3 added the comment: We need to see the parser setup as well. I've never seen a bug like this before. The `usage` line suggests that you are using subparsers. It might be better if you asked this on StackOverFlow with a repeatable code example. That's a better place to get

[issue29553] Argparser does not display closing parentheses in nested mutex groups

2017-02-22 Thread paul j3
paul j3 added the comment: I played around with the patch 117. I was wrong in thinking this was another case of excess brackets being wrongly purged. The fix works by adding ending ] that were missing the original. And it does add a symmetry to the code. But it is easy to construct a set

[issue29632] argparse values for action in add_argument() should be flags instead of (or in addition to) strings

2017-02-23 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue29632> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue29632] argparse values for action in add_argument() should be flags instead of (or in addition to) strings

2017-02-23 Thread paul j3
paul j3 added the comment: Those strings are defined in a 'parser.registry' dictionary, with expressions like self.register('action', 'store', _StoreAction) (Users can also register their own custom classes. The registry can also be used for the 'type&

[issue25882] argparse help error: arguments created by add_mutually_exclusive_group() are shown outside their parent group created by add_argument_group()

2017-02-26 Thread paul j3
paul j3 added the comment: Earlier issue on the same topic - passing a mutually exclusive group via parents http://bugs.python.org/issue16807 Can they be consolidated? -- ___ Python tracker <http://bugs.python.org/issue25

[issue29553] Argparser does not display closing parentheses in nested mutex groups

2017-02-26 Thread paul j3
paul j3 added the comment: The PR117 patch adds an apparent symmetry. There's a if/else for 'start', so shouldn't there also be one for 'end'? if start in inserts: inserts[start] += ' [' else: inserts[start] = '['

[issue29553] Argparser does not display closing parentheses in nested mutex groups

2017-02-26 Thread paul j3
paul j3 added the comment: I should probably give PR 120 more credit. By checking the group's container it in effect eliminates this overlapping action problem. Nested groups aren't used in the usage, just the union xor. Maybe the question is, which is better for the user? To te

[issue29626] Issue with spacing in argparse module while using help

2017-02-27 Thread paul j3
Changes by paul j3 : -- stage: -> resolved status: open -> closed ___ Python tracker <http://bugs.python.org/issue29626> ___ ___ Python-bugs-list

[issue29626] Issue with spacing in argparse module while using help

2017-02-27 Thread paul j3
paul j3 added the comment: With this setup import argparse parser=argparse.ArgumentParser(prog='cli') parser.add_argument('nodes') sp=parser.add_subparsers() p1 = sp.add_parser('list', description='Lists nodes in your current project') p1.add_argument(&#x

[issue29626] Issue with spacing in argparse module while using help

2017-02-27 Thread paul j3
paul j3 added the comment: This help looks normal: 1427:~/mypy/argdev$ python3 issue29626.py delete -h usage: cli delete [-h] [-p] userid Deletes a user in your organization. positional arguments: userid The userid of user. optional arguments: -h, --help show this

[issue29626] Issue with spacing in argparse module while using help

2017-02-27 Thread paul j3
paul j3 added the comment: Sorry, I missed that. For some reason I looking something bigger. That's coming from the `metavar=""'. If I specify `metavar="xxx" that help line will have -p xxx, --projectid xxx Replace the 'xxx` with '', and yo

[issue29626] Issue with spacing in argparse module while using help

2017-02-27 Thread paul j3
Changes by paul j3 : -- status: closed -> open ___ Python tracker <http://bugs.python.org/issue29626> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue9253] argparse: optional subparsers

2016-06-07 Thread paul j3
paul j3 added the comment: My answer to http://stackoverflow.com/questions/23349349/argparse-with-required-subparser is getting a slow but steady stream of + scores; so the `required subparser` issue is still bothering people. This particular question addresses the problem that the error

[issue27303] [argparse] Unify options in help output

2016-06-12 Thread paul j3
paul j3 added the comment: There are 2 issues here - - how to make the 'choices' list most compact - how to make the multiple option strings display (long and short) more compact, regardless of why the argument part is long. When the choices display is too long, 'meta

[issue27303] [argparse] Unify options in help output

2016-06-12 Thread paul j3
paul j3 added the comment: http://stackoverflow.com/questions/18275023/dont-show-long-options-twice-in-print-help-from-argparse Once answer demonstrates how to change the Formatter: class CustomHelpFormatter(argparse.HelpFormatter): def _format_action_invocation(self, action): if

[issue24419] In argparse action append_const doesn't work for positional arguments

2016-06-20 Thread paul j3
Changes by paul j3 : -- status: open -> closed ___ Python tracker <http://bugs.python.org/issue24419> ___ ___ Python-bugs-list mailing list Unsubscrib

[issue8538] Add FlagAction to argparse

2016-06-20 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue8538> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue12713] argparse: allow abbreviation of sub commands by users

2016-08-19 Thread paul j3
Changes by paul j3 : -- nosy: +paul.j3 ___ Python tracker <http://bugs.python.org/issue12713> ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue12713] argparse: allow abbreviation of sub commands by users

2016-08-19 Thread paul j3
paul j3 added the comment: I haven't read the discussion in full, but it looks like this patch was added without any recent discussion or testing. Previously if we had `choices=['a','abc']`, any exact match would be accepted, and partial matches rejected. With th

[issue24444] In argparse empty choices cannot be printed in the help

2016-08-21 Thread paul j3
paul j3 added the comment: This error is also produced by help = ' ' that is, a help line with all blanks. As long as there is a nonblank character in the help line it format fine. This issue doesn't need to be resolved by itself, but should be considered if and when th

[issue12713] argparse: allow abbreviation of sub commands by users

2016-08-21 Thread paul j3
paul j3 added the comment: Another failure case: parser.add_argument('--int', type=int, choices=[10,15,25]) '--int 15` puts 'int=15' in the Namespace. '--int 2' puts 'int=2' in the Namespace, because it matches the 'str(25)'. '--i

[issue17250] argparse: Issue 15906 patch; positional with nargs='*' and string default

2013-02-19 Thread paul j3
New submission from paul j3: The production argparse applies the type conversion to a string default whether it is needed or not. With the 12776 and 15906 patch, that conversion is postponed, so that it is applied only once. However, for a positional argument with nargs='*', that

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2013-03-14 Thread paul j3
paul j3 added the comment: If nargs=2, type=float, an argv like '1e4 -.002' works, but '1e4 -2e-3' produces the same error as discussed here. The problem is that _negative_number_matcher does not handle scientific notation. The proposed generalize matcher, r'^-.+

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2013-03-14 Thread paul j3
paul j3 added the comment: We need to be careful about when or where _negative_number_match is changed. " We basically do: parser = argparse.ArgumentParser(...) parser._negative_number_matcher = re.compile(r'^-.+$') " This changes the value for the parser itself, bu

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2013-03-14 Thread paul j3
paul j3 added the comment: While parser._negative_number_matcher is used during parser.parse_args() to check whether an argument string is a 'negative number' (and hence whether to classify it as A or O). parser._optionals._negative_number_matcher is used during parser.add_arg

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2013-03-17 Thread paul j3
paul j3 added the comment: I think the `re.compile(r'^-.+$')` behavior could be better achieved by inserting a simple test in `_parse_optional` before the `_negative_number_matcher` test. # behave more like optparse even if the argument looks like a opt

[issue9334] argparse does not accept options taking arguments beginning with dash (regression from optparse)

2013-03-22 Thread paul j3
paul j3 added the comment: This patch makes two changes to argparse.py ArgumentParser._parse_optional() - accept negative scientific and complex numbers - add the args_default_to_positional parser option _negative_number_matcher only matches integers and simple floats. This is fine for

[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(&

[issue15427] Describe use of args parameter of argparse.ArgumentParser.parse_args

2013-04-02 Thread paul j3
paul j3 added the comment: The 'args=' parameter is the same as the first positional parameter used in most of the examples. That is normal Python behavior. 15.4.4.5. Beyond sys.argv explains this alternative way of specifying argv. Still 2 bullet points could be added to 15.4.4.

[issue15427] Describe use of args parameter of argparse.ArgumentParser.parse_args

2013-04-02 Thread paul j3
paul j3 added the comment: This patch to argparse.rst adds the argument points to parse_args(). It also adds two points to the 'Upgrading optparse code' section, one about using 'nargs=argparse.REMAINDER', and other about 'parse_known_args()'. I'm not en

[issue15427] Describe use of args parameter of argparse.ArgumentParser.parse_args

2013-04-03 Thread paul j3
paul j3 added the comment: I changed the reference to the optparse allow_interspersed_args attribute to the disable_interspersed_args() method. -- Added file: http://bugs.python.org/file29662/remainder.patch ___ Python tracker <h

[issue13966] Add disable_interspersed_args() to argparse.ArgumentParser

2013-04-03 Thread paul j3
paul j3 added the comment: The optparse page gives a reason for disable_interspersed_args(): "Use this if you have a command processor which runs another command which has options of its own and you want to make sure these options don’t get confused. For example, each command might h

[issue16399] argparse: append action with default list adds to list instead of overriding

2013-04-03 Thread paul j3
paul j3 added the comment: The test file, test_argparse.py, has a test case for this: 'class TestOptionalsActionAppendWithDefault' argument_signatures = [Sig('--baz', action='append', default=['X'])] successes = [

[issue13966] Add disable_interspersed_args() to argparse.ArgumentParser

2013-04-03 Thread paul j3
paul j3 added the comment: Oops, I was wrong about this: "Argparse doesn't prohibit all interspersed positionals. You could, for example, have one or more positionals with other nargs that could be interspersed. But the REMAINDER one has to be last." parser.

[issue13966] Add disable_interspersed_args() to argparse.ArgumentParser

2013-04-04 Thread paul j3
paul j3 added the comment: Looking further at test_argparse.py, I should say that the behavior of multiple positionals when there is one cluster of positional argstrings is well illustrated in the tests. It's the behavior when there are multiple clusters (interspersed positionals) tha

[issue13922] argparse handling multiple "--" in args improperly

2013-04-05 Thread paul j3
paul j3 added the comment: There are several problems with the patch provided in msg156315 This description: "Added patch so that only the first '--' is removed by an argparse.PARSE or argparse.REMAINDER argument." should read "Added patch so that only the first &#x

[issue13922] argparse handling multiple "--" in args improperly

2013-04-05 Thread paul j3
paul j3 added the comment: There's another 'feature' to the patch proposed here. It only deletes the first '--' in the list of strings passed to '_get_values' for a particular action. parser = argparse.ArgumentParser() parser.add_argument('fo

[issue13922] argparse handling multiple "--" in args improperly

2013-04-05 Thread paul j3
paul j3 added the comment: I am working on an alternative solution that moves the '--' removal to the consume_positionals() method, and only does it if there is a corresponding '-' in the arg_strings_pattern. -- ___ P

<    1   2   3   4   5   6   7   8   >