What is "lambda x=x : ... " ?

Fredrik Lundh fredrik at pythonware.com
Thu Jan 10 20:52:07 CET 2008

Mike Meyer wrote:

>>>> What does "y=y" and "c=c" mean in the lambda function?
>>> Older versions of python didn't make variables in an outer scope
>>> visible in the inner scope. This was the standard idiom to work
>>> around that.
>> lexically scoped free variables and object binding are two different 
>> things, and have different semantics.  the former does not always 
>> replace the latter.
> And?

and what?  it's not the same thing.  the "newer" idiom only replaces
the "older" idiom under certain circumstances (such as in the OP's first 
example, but *not* in his second example).


More information about the Python-list mailing list