[issue24419] In argparse action append_const doesn't work for positional arguments
paul j3
report at bugs.python.org
Thu Jun 18 04:35:43 CEST 2015
paul j3 added the comment:
None of the `append` actions makes sense with positionals. The name (and hence the 'dest') must be unique. And positionals can't be repeated.
There are other ways to put a pair of values in the Namespace. For example, after parsing
args.x = [42, 43]
or before
ns = argparse.Namespace(x=[42,43])
parser.parse_args(namespace=ns)
or the `const` (or better the default) could be `[42, 43]`.
Plain `append` might let you put `[42,43]` in the dest via the default, and then append further values to that list (from the user). I'd have to test that.
It might be instructive to look at the `test_argparse.py` file, and search for test cases that use `append` or `const`.
----------
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24419>
_______________________________________
More information about the Python-bugs-list
mailing list