[Python-ideas] Dict joining using + and +=

Serhiy Storchaka storchaka at gmail.com
Fri Mar 1 01:29:06 EST 2019


28.02.19 23:19, Greg Ewing пише:
> Serhiy Storchaka wrote:
>> I do not understand why we discuss a new syntax for dict merging if we 
>> already have a syntax for dict merging: {**d1, **d2} (which works with 
>> *all* mappings).
> 
> But that always returns a dict. A '+' operator could be implemented
> by other mapping types to return a mapping of the same type.

And this opens a non-easy problem: how to create a mapping of the same 
type? Not all mappings, and even not all dict subclasses have a copying 
constructor.



More information about the Python-ideas mailing list