I need a callback function that is almost exactly the same for a series of gui events. The function will behave slightly differently depending on which event has called it.
the soluiton to lambda is more lambda
In [0]: funcs = [(lambda j: (lambda: j))(i) for i in ('do', 're', 'mi')]
In [1]: funcs
Out[1]:
[>,
>,
>]
In [2]: [f() for f in funcs]
Out[2]: ['do', 're', 'mi']
the outer lambda
is used to bind the current value of i
to j
at the
each time the outer lambda
is called it makes an instance of the inner lambda
with j
bound to the current value of i
as i
's value