[Python-ideas] PEP: Dict addition and subtraction
jfine2358 at gmail.com
Fri Mar 22 03:47:01 EDT 2019
Chris Angelico wrote:
> The trouble with that is that you can't always use a dict subclass (or
> a non-subclass MutableMapping implementation, etc, etc, etc). There
> are MANY situations in which Python will give you an actual real dict,
> and it defeats the purpose if you then have to construct an
> AddableDict out of it just so you can add something to it. Not every
> proposed change makes sense on PyPI, and it definitely won't get a
> fair representation in "practical experience".
Chris seems to accept that sometimes you can use a dict subclass, and
that my proposal will give some representation of "practical
Even if not perfect, such benefits are I think worth having. And Chris
gives no evidence (or examples) beyond his own assertions, that my
proposal would not produce a fair representation of practical
Why don't we just try it and see. This would engage us with the users.
And it would, as I suggested, clarify and document the syntax and
semantics. And provide backporting to current versions of Python.
By the way, in "Masterminds of Programming" [page 20], Guido gives
four lines of defence against the unwise addition of a "favorite
feature" to the language. They are
 Explain to people that they can already do what they want.
 Tell them to write their own module or class to encapsulate the feature.
 Accept the feature, as pure Python, in the standard library.
 Accept the feature as a C-Python extension standard.
And  is, in Guido's words
> the last line of defense before we have to admit [...]
> this is so useful [...] so we'll have to change the language
I think the pure Python implementation is important. If the supporters
of this proposal are not willing to provide this, then I will (along
with anyone else who volunteers).
http://shop.oreilly.com/product/9780596515171.do # Masterminds of Programming
More information about the Python-ideas