[Python-ideas] Allow using ** twice
Stephen J. Turnbull
stephen at xemacs.org
Fri Jun 7 09:23:35 CEST 2013
Andrew Barnert writes:
> On Jun 6, 2013, at 8:43, Haoyi Li <haoyi.sg at gmail.com> wrote:
> There should be one way to do it...I'd agree except, well, there
> are two different things that people want to do here!
> Actually, there's three:
Four: associate a multivalue containing all of the individual values
to the key (sort of a set-valued Counter). (This comes up in practice
in applications that assume UUIDs on the Internet, especially in mail.
For example, when I receive a post via both a mailing list and a
personal copy, eventually I want to save the mailing list's version in
preference to the personal copy. But I only want to display one
version in the MUA. In archiving, you run into the occasional author
who provides their own non-unique message ID conflicting with a
*different* message. Etc.)
And somebody was just asking for Counter addition. Counter is a dict
subclass, so "dict(...) + dict(...) = updated_dict" would imply really
perverse semantics for "Counter(...) + Counter(...)".
How about extending .update to take multiple positional arguments?
Then TOOWTDI idiom would be
{}.update(d1, d2, ...)
The "first found wins" interpretation could use a different method:
{}.extend(d1, d2, ...)
More information about the Python-ideas
mailing list