lambda & scope

Alex not_such_a_brain_after_all at mit.edu
Sun Nov 5 21:09:24 EST 2000


Pass the variable value as a default argument:

lambda x, scale=scale, x * scale, v

But for that particular fragment, in python2.0, you would be better off
going for a list comprehension:

def fred(scale):
    v = [1, 2, 3]
    v = [x*scale for x in v]

Alex.

-- 
Speak softly but carry a big carrot.




More information about the Python-list mailing list