lambda without vars?

Alex alex at somewhere.round.here
Wed Mar 15 11:44:17 EST 2000


>    a = filter(lambda x, y=y: x<y, xList)
> 
> However, you cannot have the function to modify such variables (that
> is, the value they have outside lambda).

Except for in-place modification of the object they refer to:

>>> l = []
>>> (lambda l=l: l.append (1)) ()
>>> l
[1]

Alex.



More information about the Python-list mailing list