On Thu, Apr 12, 2012 at 7:15 AM, Tim Golden <m...@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 {:>
-- http://mail.python.org/mailman/listinfo/python-list