[Python-ideas] [Python-Dev] hello, new dict addition for new eve ?

Jakob Bowyer jkbbwr at gmail.com
Fri Dec 30 20:39:13 CET 2011

Not that I'm smart enough to really contribute to these discussions but wouldn't it be an idea to have dictionary addition turn the values from d2 into d1 so that

d1 = {1:1,2:2,3:3} 
d2 = {1:2,2:2,4:4}
d3 = d1 + d2 
print d3
# {1:2,2:2,3:3,4:4}
# but 
d4 = d2 + d1
print d4
# {1:1,2:2,3:3,4:4}

Meaning that replacement is conditional on which side the other dictionary is on with the + operator. This might be harder to understand. So it's not a great idea... Still throwing it in the ring is the only way to learn

Sent from my iPad

On 30 Dec 2011, at 17:12, Eric Snow <ericsnowcurrently at gmail.com> wrote:

> On Fri, Dec 30, 2011 at 10:02 AM, Guido van Rossum <guido at python.org> wrote:
>> What I meant is similar to set union on the keys, where if a key exists in
>> both dicts, the value in the result is equal to one of the values in the
>> operands (and if the value is the same for both operands, that value is also
>> the result value).
> +1
> This is the one I was thinking of too.
> -eric
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> http://mail.python.org/mailman/listinfo/python-ideas

More information about the Python-ideas mailing list