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

zslevi@gmail.com levilista at gmail.com
Thu Jan 10 13:25:27 EST 2008


I'm reading this page: http://www.ps.uni-sb.de/~duchier/python/continuations.html
and I've found a strange usage of lambda:

####################
Now, CPS would transform the baz function above into:

def baz(x,y,c):
        mul(2,x,lambda v,y=y,c=c: add(v,y,c))

###################

What does "y=y" and "c=c" mean in the lambda function?
I thought it bounds the outer variables, so I experimented a little
bit:

#################
x = 3
y = lambda x=x : x+10

print y(2)
##################

It prints 12, so it doesn't bind the variable in the outer scope.



More information about the Python-list mailing list