[EMAIL PROTECTED] wrote: > Bruno Desthuilliers: >> You mean : "to people that don't bother reading the FineManual *nor* >> searching the newsgroup / ML archives ?" > > Are there ways to change how Python3 manages arguments and functions, > to remove this antifeature of Python, avoiding this common mistake > done by every newbie? > I don't care if it reduces the performance of Python a little. > You can't just copy the default values on every call: you would still get people confused by the semantics whether you did a shallow or deep copy or as now no copy. I don't think simply re-executing the default argument expression on each call works either: that would confuse at least as many people as the current system.
It would be possible, but extremely annoying to limit default arguments to being literal constants, or slightly less drastically limit them to being of types known to be immutable. Of course that blocks you from using any user defined types unless you invent some kind of scheme for declaring that a type is safe to use as a default argument. Another option might just be to generate a warning the first time a program uses a not obviously immutable default. I think in this situation the best solution is to expect people to learn to use the language, and accept that those people who don't RTFM will keep on asking here. Even if you could change the behaviour of default arguments we would still get equivalent regular questions from the people who initialise class attributes with lists or dictionaries. -- Duncan Booth http://kupuguy.blogspot.com -- http://mail.python.org/mailman/listinfo/python-list