I think this takes the discussion in a more practical direction. Imagine that there were a special method name __immutable__ to be implemented appropriately by all builtin types. Any object passed as a default argument would be checked to see that its type implements __immutable__ and that __immutable__() is True. Failure would mean a warning or even an error in subsequent versions.

User-defined types could implement __immutable__ as they saw fit, in the traditional Pythonic consenting-adults-ly way.

On Thu, May 14, 2009 at 9:16 PM, Tennessee Leeuwenburg <tleeuwenburg@gmail.com> wrote:
A thought from another direction...

Any chance we could have the interpreter raise a warning for the case

def foo(a = []):
  #stuff

?

The empty list and empty dict args would, I imagine, be the two most common mistakes. Showing a warning might, at least, solve the problem of people tripping over the syntax.

Cheers,
-T

_______________________________________________
Python-ideas mailing list
Python-ideas@python.org
http://mail.python.org/mailman/listinfo/python-ideas