Mutable default values for function parameters
Erik Max Francis
max at alcyone.com
Thu Oct 4 15:14:00 EDT 2001
Brian Quinlan wrote:
> Those should raise some sort of exception, not silently do the
> default.
>
> You could change it to:
> d = (d is None) or []
That won't work either. d is None evalutes to 1, not d, so when d is
None d will get replaced with 1, not with a new empty list.
--
Erik Max Francis / max at alcyone.com / http://www.alcyone.com/max/
__ San Jose, CA, US / 37 20 N 121 53 W / ICQ16063900 / &tSftDotIotE
/ \ Give me chastity, but not yet.
\__/ St. Augustine
Crank Dot Net / http://www.crank.net/
Cranks, crackpots, kooks, & loons on the Net.
More information about the Python-list
mailing list