Re:PEP 584 – Add + and – operators to the built-in dict class
by kbd on Wednesday March 06, 2019 @02:59PM
(#19322180)
> it’s not super obvious what to do when the keys are equal
is equivalent to:
[ Parent
| on HN ]
Re:PEP 584 – Add + and – operators to the built-in dict class
by dan-robertson on Wednesday March 06, 2019 @03:11PM
(#19322293)
Now read the above but instead of “it’s not super obvious what
d1 | d2
should be because losing information/desirable properties/weird errors”, read “it’s not super obvious what {**d1, **d2}
should be because losing information/desirable properties/weird errors”.Except I guess one could throw in something about TOOWTDI too.
Re:PEP 584 – Add + and – operators to the built-in dict class
by kbd on Wednesday March 06, 2019 @03:42PM
(#19322542)
I actually think it is obvious what a dictionary merge should do (overwrite keys on the left with keys on the right), but this is besides the point because it's already been determined for
{**d1, **d2}
In other words, there are no new semantics to discuss here. I'm just saying the two syntaxes should be equivalent.