explain this function to me, lambda confusion

globalrev skanemupp at yahoo.se
Wed May 7 17:38:15 EDT 2008


i have a rough understanding of lambda but so far only have found use
for it once(in tkinter when passing lambda as an argument i could
circumvent some tricky stuff).
what is the point of the following function?

def addn(n):
		return lambda x,inc=n: x+inc

if i do addn(5) it returns


>>> def addn(n):
		return lambda x,inc=n: x+inc


>>> addn(5)
<function <lambda> at 0x01D81830>


ok? so what do i write to make it actually do something. and is the
inc=n necessary i cant do x+n?



More information about the Python-list mailing list