[Python-ideas] PEP: Dict addition and subtraction

Stefan Behnel stefan_ml at behnel.de
Mon Mar 4 04:51:58 EST 2019


Jimmy Girardet schrieb am 04.03.19 um 10:12:
> I'm not old on this list but every time there is a proposal, the answer
> is "what are you trying to solve ?".
> 
> Since
> 
> |z ={**x,**y} and z.update(y) Exists, I can"t find the answer.

I think the main intentions is to close a gap in the language.

    [1,2,3] + [4,5,6]

works for lists and tuples,

    {1,2,3} | {4,5,6}

works for sets, but joining two dicts isn't simply

    {1:2, 3:4} + {5:6}

but requires either some obscure syntax or a statement instead of a simple
expression.

The proposal is to enable the obvious syntax for something that should be
obvious.

Stefan



More information about the Python-ideas mailing list