Why doesn't python's list append() method return the list itself?

Raymond Hettinger python at rcn.com
Sun Jul 11 20:55:53 EDT 2010


On Jul 11, 8:59 am, dhruvbird <dhruvb... at gmail.com> wrote:
> Why doesn't python's list append() method return the list itself? For
> that matter, even the reverse() and sort() methods?

Because Guido thinks that having those methods return None is the best
way to communicate that the underlying object has been mutated in-
place.

Some other languages do it differently, but this is Guido's language,
so we do it his way.


Raymond



More information about the Python-list mailing list