On 20/04/2020 16:57, Christopher Barker wrote:
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.
I think you may have made the same mistake I initially did. The OP isn't asking for the mutated list to be returned, they are asking for the object added. Which pretty much proves my point about it being really unexpected ;-)
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
-- ∞
-- Rhodri James *-* Kynesim Ltd