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

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Mar 1 17:33:31 EST 2019


Serhiy Storchaka wrote:
> And this opens a non-easy problem: how to create a mapping of the same 
> type?

That's the responsibility of the class implementing the + operator.

There doesn't have to be any guarantee that a subclass of it will
automatically return an instance of the subclass (many existing
types provide no such guarantee, e.g. + on strings), so whatever
strategy it uses doesn't have to be part of its public API.

-- 
Greg


More information about the Python-ideas mailing list