[New-bugs-announce] [issue23378] argparse.add_argument action parameter should allow value extend

the mulhern report at bugs.python.org
Mon Feb 2 15:23:10 CET 2015


New submission from the mulhern:

As well as the append action it would be convenient for there to be an extend action.

This is kind of useful to allow something like:

parser.add_argument("--foo", action="extend", nargs="+", type=str)

given

parser.parse_args("--foo f1 --foo f2 f3 f4".split())

to result in

["f1", "f2", "f3", "f4"].

The action "append" results in

[["f1"], ["f2", "f3", "f4"]]

And action store in

["f2", "f3", "f4"].

It is easy to write a custom action, but it feels like a fairly common requirement.

Probably it would make sense to extend the default, similarly to how append behaves.

----------
components: Library (Lib)
messages: 235260
nosy: the.mulhern
priority: normal
severity: normal
status: open
title: argparse.add_argument action parameter should allow value extend
type: enhancement
versions: Python 3.4, Python 3.5, Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue23378>
_______________________________________


More information about the New-bugs-announce mailing list