On Apr 22, 2020, at 15:04, [email protected] wrote:
> 
> 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).

I’m pretty sure I’ve run into the exact same situation (well, not accumulating 
filters, but accumulating something and wanting to add multiple constants from 
one flag), had the same “Really? It’s not there?” reaction as you, and then 
just muttered and worked around it. It makes sense to me to fix it, exactly the 
way you propose.

My only comment is that when you write the example(s) for the docs, it might be 
worth using a tuple rather than a list for the const value. It doesn’t really 
make a difference, but people might be momentarily confused by a mutable list 
called “const”.

Also, looking at the _copy_items function you’re calling: it has a comment 
saying it’s only used by append and append_const, but that’s wrong as it’s also 
used by extend. And of course you’re adding extend_const. I don’t know if 
that’s worth fixing separately, but if not it seems to me it’s probably worth 
fixing in your patch.
_______________________________________________
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/VGXVYH5ICUJSMMWWZZGBDHBUIYFA5IWT/
Code of Conduct: http://python.org/psf/codeofconduct/

Reply via email to