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 <rep...@bugs.python.org>
<http://bugs.python.org/issue23378>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to