Not understanding lamdas and scoping
Joshua Kugler
jkugler at bigfoot.com
Wed Mar 26 18:03:11 EDT 2008
George Sakkis wrote:
> On Mar 26, 5:02 pm, Joshua Kugler <jkug... at bigfoot.com> wrote:
>
>> I am trying to use lamdba to generate some functions, and it is not
>> working
>> the way I'd expect. The code is below, followed by the results I'm
>> getting. More comments below that.
>>
>> (...)
>>
>> So, is there some scoping issue with lambda
>> that I'm not seeing?
>
> Yes; it's not related to lambda though but to closures (whether
> defined as lambdas or regular functions). See for example
>
http://groups.google.com/group/comp.lang.python/browse_frm/thread/94d1bba8ad56baf4
>
> There should be an entry for this at
> http://www.python.org/doc/faq/programming/, that's really an FAQ.
George -
Thanks for the quick and clear answer...that makes perfect sense. To
bad...I'd like to just use a list comprehension. :)
j
More information about the Python-list
mailing list