List mutation method gotcha - How well known?
sjmachin at lexicon.net
Thu Mar 13 22:00:49 CET 2008
On Mar 14, 6:13 am, Arnaud Delobelle <arno... at googlemail.com> wrote:
> On Mar 13, 10:42 am, Paul Rubin <http://phr...@NOSPAM.invalid> wrote:
> > By Python convention, methods that mutate the object return None, and
> > also stuff that returns None doesn't generate output at the
> > interactive prompt.
> A convention that does not always hold:
> >>> l = [1, 2, 3]
> >>> l.pop()
> >>> l
> [1, 2]
Try this then for the "convention": Any function/method that is not
documented to return something else should be assumed to return None.
Note: no nexus with whether or not the function/method mutates its
More information about the Python-list