Forgive me if this idea has been discussed before, I searched the mailing 
lists, the CPython repo, and the issue tracker and was unable to find anything.

I have found myself a few times in a position where I have a repeated argument 
that uses the `append` action, along with some convenience arguments that 
append a specific const to that same dest (eg:  `--filter-x` being made 
equivalent to `--filter x` via `append_const`). This is particularly useful in 
cli apps that expose some kind of powerful-but-verbose filtering capability, 
while also providing shorter aliases for common invocations. I'm sure there are 
other use cases, but this is the one I'm most familiar with.

The natural extension to this filtering idea are convenience args that set two 
const values (eg: `--filter x --filter y` being equivalent to `--filter-x-y`), 
but there is no `extend_const` action to enable this.

While this is possible (and rather straight forward) to add via a custom 
action, I feel like this should be a built-in action instead. `append` has 
`append_const`, it seems intuitive and reasonable to expect `extend` to have 
`extend_const` too (my anecdotal experience the first time I came across this 
need was that I simply tried using `extend_const` without checking the docs, 
assuming it already existed).

Please see this gist for a working example that may help explain the idea and 
intended use case more clearly: 
https://gist.github.com/roganartu/7c2ec129d868ecda95acfbd655ef0ab2
_______________________________________________
Python-ideas mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at 
https://mail.python.org/archives/list/[email protected]/message/7ZHY7HFFQHIX3YWWCIJTNB4DRG2NQDOV/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to