3 ms·
Regarding this one: http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Default_Argument_Values#Default_Argument_Values http://google-styleg
by shawnps 14y ago
Regarding this one:
http://google-styleguide.googlecode.com/svn/trunk/pyguide.html?showone=Default_Argument_Values#Default_Argument_Values http://google-styleguide.googlecode.com/svn/trunk/pyguide.ht...
I commented about this on another post. There's a nice explanation here as to why using mutable objects as default values in function/method definitions is bad:
http://effbot.org/zone/default-values.htm http://effbot.org/zone/default-values.htm
In short, it can be bad to set default arguments to mutable objects because the function keeps using the same object in each call.
- toyg 14y agoThat's a classic Python gotcha, mentioned in all books and tutorials nowadays.