[Python-ideas] Fwd: Adding "+" and "+=" operators to dict
Chris Barker
chris.barker at noaa.gov
Sat Feb 14 06:16:41 CET 2015
Oops,
Accidentally went off-list -- here it is:
On Fri, Feb 13, 2015 at 8:32 PM, Greg Ewing <greg.ewing at canterbury.ac.nz>
wrote:
> Steven D'Aprano wrote:
>
>> I think that focusing on the question of "which wins" in the case of
>> duplicate keys, the left or right operand, is not very productive. We can
>> just declare that Python semantics are that the last value seen wins,
>>
>
> Sure we can, but that's something to be learned. It's
> not going to be obvious to everyone.
no -- but some things are more obvious to more people than others.
dict1 + dict2
being the same as
dict1.update(dict2)
Is pretty easy to explain, and probably the most likely to be intuitively
obvious to the most people.
It might be interesting to put a poll on a more general list:
What do you think the result of :
dict1 = {'a':1, 'b':2}
dict2 = {'c':3, 'b':4}
dict3 = dict1 + dict2
to be?
And see what shakes out with a mixture of newbies and more experienced
pythoneers think.
This is a pretty classic usability issue -- "intuitive" means "works like
one expects" , but everyone expects different things, so different things
are intuitive to different people. So often there is NO ONE thing that is
most intuitive to everyone.
But the only way to know is some usability testing.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Chris.Barker at noaa.gov
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150213/39a69daf/attachment.html>
More information about the Python-ideas
mailing list