Why return None?
Erik Max Francis
max at alcyone.com
Wed Aug 25 23:56:05 CEST 2004
Martin DeMello wrote:
> Yes, but why? I mean, is there either an advantage to returning None
> some inherent danger in returning self?
The "inherent danger" is that the user might think that it returns a new
object rather than mutating the original. Returning a new object vs.
mutating the argument and returning None is merely a convention, but
it's one used consistently in the Python standard library.
__ Erik Max Francis && max at alcyone.com && http://www.alcyone.com/max/
/ \ San Jose, CA, USA && 37 20 N 121 53 W && AIM erikmaxfrancis
\__/ Trying to mend our hearts in vain
-- Sandra St. Victor
More information about the Python-list