[Python-ideas] Suggestions: dict.flow_update and dict.__add__

Jonathan Fine jfine2358 at gmail.com
Tue Mar 5 12:09:19 EST 2019

I thank Guido and Christopher for their thoughtful comments. You
certainly found some weak points. I chose the name 'flow' to match:

Instead of my previous

   arg = defaults.copy().flow_update(options)

one could instead from somewhere import flow, and then write

   arg = flow(defaults.copy()).update(options)

This avoids a profusion of flow_ methods, and also the need to
subclass dict. Once could of course use a different name. Perhaps
'follow' would be better. And it would work 'out the box' in other

Christopher might prefer the flow(obj).update approach, as it respects
the convention "mutating methods do not return self." (Thank you for
your clear statement, Christopher.)

(Aside: For the non-experts, a word if I may about the implementation.
The key point is that in Python the programmer 'owns the dot' and so
the desired semantics can be implemented. We use a custom
__getattribute__ .)

Finally, please forgive my fictional use case. I think studying
real-world use cases for dict + dict would be very helpful to the
discussion. I don't recall seeing any, but I haven't looked hard.
Instructive use cases should, of course, be placed in the PEP.


More information about the Python-ideas mailing list