[Python-ideas] Default arguments in Python - the return - running out of ideas but...

Curt Hagenlocher curt at hagenlocher.org
Fri May 15 06:31:34 CEST 2009


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 at 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 at python.org
> http://mail.python.org/mailman/listinfo/python-ideas
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20090514/fdfc4f17/attachment.html>


More information about the Python-ideas mailing list