Re:PEP 584 – Add + and – operators to the built-in dict class
by jessaustin on Wednesday March 06, 2019 @11:36AM
(#19320184)
ISTM the most logical result would be:
...but I could certainly understand throwing an exception.
[ Parent
| on HN ]
Re:PEP 584 – Add + and – operators to the built-in dict class
by xiao_haozi on Wednesday March 06, 2019 @01:20PM
(#19321182)
While I see your point, I don't think this makes sense historically. Dictionaries never supported such behavior before so you'd be introducing a new core concept to a dictionary. But moreover, you'd be changing the type of the value only on duplicated keys, and what about if you were to add another value of 2 to a? Are you making this a set, and why? I think it would come with too many caveats and assumptions in the PEP.
I'm not saying you have a bad idea/logic here, just that I'm not sure it's the best thing for the dict.
Re:PEP 584 – Add + and – operators to the built-in dict class
by dan-robertson on Wednesday March 06, 2019 @03:21PM
(#19322381)
Note that this forgets the order of the arguments, which may not be desirable