Emile van Sebille schrieb:
Steven D'Aprano wrote:
Sometimes it seems that barely a day goes by without some newbie, or not-
so-newbie, getting confused by the behaviour of functions with mutable
default arguments. No sooner does one thread finally, and painfully,
fade away than another one starts up.
I suggest that Python should raise warnings.RuntimeWarning (or
similar?) when a function is defined with a default argument
consisting of a list, dict or set. (This is not meant as an exhaustive
list of all possible mutable types, but as the most common ones that I
expect will trip up newbies.) The warning should refer to the relevant
FAQ or section in the docs.
What do people think?
-1
People that have worked through the tutorial, something everyone should
do when they're starting out, will find this explicitly discussed. See
http://docs.python.org/tut/node6.html#SECTION006710000000000000000
People that just skim the surface get stung -- sorry.
But obviously enough, it's not emphazized enough. Even if the
interpreter isn't touched, at least the docs should be.
Diez
--
http://mail.python.org/mailman/listinfo/python-list