It is a standard convention in Python that mutating methods return None. 

While that does make chaining operations harder (impossible), it is a consistent convention that makes it much harder to get confused about whether a method mutates or not.

It is not going to change.

See previous threads about a “fluent” interface for discussion about the concept.

-CHB

On Mon, Apr 20, 2020 at 8:42 AM J. Pic <jpic@yourlabs.org> wrote:
Hi all,

Currently, list.append(x) mutates the list and returns None.

It would be a little syntactic sugar to return x, for example:

    something = mylist.append(Something())

What do you think ?

Thanks in advance for your replies

--

_______________________________________________
Python-ideas mailing list -- python-ideas@python.org
To unsubscribe send an email to python-ideas-leave@python.org
https://mail.python.org/mailman3/lists/python-ideas.python.org/
Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/3RHQB6FLE2LDFWOIGLKXCAKPF43LUIVA/
Code of Conduct: http://python.org/psf/codeofconduct/
--
Christopher Barker, PhD

Python Language Consulting
  - Teaching
  - Scientific Software Development
  - Desktop GUI and Web Development
  - wxPython, numpy, scipy, Cython