Unexpected Python Behavior

Michael Hoffman m.h.3.9.1.without.dots.at.cam.ac.uk at example.com
Fri Sep 24 09:48:37 EDT 2004


David Pokorny wrote:

> "Because of this feature, it is good programming practice to not use mutable
> objects as default values." -- 
> http://www.python.org/doc/faq/general.html#why-are-default-values-shared-between-objects
> 
> Has it been discussed whether it would be a good idea to issue a warning in
> this case?

It's not.

> It strikes me that a warning wouldn't bother veteran programmers,
> since it is really easy to avoid using a mutable default value (nearly
> trivial to modify code that does use mutable default values). I'd imagine it
> makes code more readable too.

I think you're missing the usefulness of this feature. Go back to the 
link you included and read the next paragraph, "This feature can be useful."
--
Michael Hoffman



More information about the Python-list mailing list