[Python-ideas] PEP: Dict addition and subtraction

Steven D'Aprano steve at pearwood.info
Fri Mar 22 05:53:22 EDT 2019

On Fri, Mar 22, 2019 at 07:59:03AM +0000, Jonathan Fine wrote:
> Steven D'Aprano wrote:
> > (For the record, the PEP isn't set in stone in regards to the choice of
> > operator.
> Steven: Please say what parts of the PEP you consider to be set in
> stone. This will allow discussion to focus on essentials rather than
> details.

The PEP is primarily about making a merge operator, so that stays, 
regardless of whether it's spelled + | or something else. Otherwise 
there's no point to the PEP.

If there is demand for a merged() method/function, that go into a 
competing PEP, but it won't be part of this PEP.

If anyone wants to propose syntax for chained method calls (fluent 
programming) so we can write d.copy().update(), that won't be in this 
PEP either. Likewise for new syntax to turn method calls into operators. 
Feel free to propose a competing PEP (and I might even support yours, if 
it makes a good enough case).

A grey area is the "last wins" merge behaviour matching update(). In 
theory, if somebody made an absolutely brilliant case for some other 
behaviour, I could change my mind, but it would have to be pretty 
amazing. In the absence of such, I'm going to use my perogative as PEP 
author to choose the behaviour I prefer to see, and leave alternatives 
to subclasses.


More information about the Python-ideas mailing list