Re: lambda closure question

From: Ted Lilley (ted.lilley_at_gmail.com)
Date: 02/20/05


Date: 19 Feb 2005 20:00:41 -0800

Wow, a lot of great discussion. Almost a bit too much for me to
grasp...I do see two or more nuggets that really address my issue.

As a side note, I'm familiar with the term currying from a friend who
learned ML and Scheme quite some time ago. Not sure if that's the true
origin, but it was a sufficiently different context from Python (or at
least I thought) that I didn't want to rely on its meaning. I was also
sufficiently unsure of it's _exact_ meaning, since we're talking about
two slightly different models, that I didn't want to use the term for
that reason as well. It's gratifying to know that it was a relevant
concept afterall, the partial function application discussion
notwithstanding. It's also gratifying to see such a strong community
versed in functional programming styles. Although I've only started
working with FP in Python, it's been a useful tool for making my
programming simpler.

The first useful nugget is the crystalization method. I spent some
time thinking about the problem after I posted it and came up with the
same workaround, in fact, the exact same syntax. It's a bit inelegant,
but it gets the job done for what I want to do. I won't even attempt
to take a position in the debate about whether Python should work by
default the way it does or the way I want to use it. ;) Seems we have
well-spoken advocates for both sides.

The other nifty nugget is Kent's suggestion for using old-style Python
default arguments to capture the variable value. Since it looks
slightly more elegant I'm going to give it a shot.

I have to say, I was happily surprised by the volume and quality of
response to my little issue. Thanks everyone!

Ted