lambda without vars?

Alex alex at somewhere.round.here
Wed Mar 15 17:44:17 CET 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