Python rocks

Alex Martelli aleax at mac.com
Sat Jun 2 21:07:04 EDT 2007


Josiah Carlson <josiah.carlson at sbcglobal.net> wrote:

> > pitfall of Python is knowing whether an operation is destructive or not.
> 
> If it returns None, it probably changes the content of an object.

A reasonable heuristic, but with lots of exceptions, alas:
    somedict.get(somekey)
will often return None without performing any change, while
    somelist.pop()
does modify somelist but typically returns non-None.

The use of trailing-exclamation-point (by convention) to indicate
"mutating methods" is a nice plus in languages that allow it.


Alex



More information about the Python-list mailing list