is this foolish?

Karl Knechtel zahlman at gmail.com
Thu Apr 12 07:49:05 EDT 2012


On Thu, Apr 12, 2012 at 7:15 AM, Tim Golden <mail at timgolden.me.uk> wrote:

> On 12/04/2012 10:35, Cameron Simpson wrote:
> > I've found myself using a Python gotcha as a feature.
>
> Have a look at Peter Inglesby's lightning talk from a
> recent London Python Dojo:
>
>  http://inglesp.github.com/2012/03/24/mutable-default-arguments.html
>
>
That's interesting, but you can get the same effect with a function
attribute, if you really don't want to write a class... that way also
protects you against accidentally passing something in to override the
default. (Incidentally: I feel that the "lambda x = x: ..." idiom to avoid
multiple closures sharing state is an ugly hack, for the same reason.)


-- 
~Zahlman {:>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20120412/d54b47f9/attachment-0001.html>


More information about the Python-list mailing list