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

Christopher Barker pythonchb at gmail.com
Tue Mar 5 11:11:06 EST 2019


On Tue, Mar 5, 2019 at 12:53 AM Jonathan Fine <jfine2358 at gmail.com> wrote:

> SUMMARY
> Instead of using dict + dict, perhaps use dict.flow_update. Here,
> flow_update is just like update, except that it returns self.


That violates an important convention in Python: mutating methods do not
return self. We really want to preserve that convention.

On the other hand, as seen in other recent threads, there is a desire for
chaining operations of many sorts, so a .flow_update() that returned a new
dict would provide that feature.

Though I would only recommend that if it was decided that we wanted to
generally support that approach for all mutable containers — which would
mean adding quite a few methods.

And we could then use the same naming convention for them all.

I’m not sure I like “flow_” though, it’s not very commonly known jargon.

-CHB

-- 
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20190305/652e092d/attachment.html>


More information about the Python-ideas mailing list