lambda question

Corrado Gioannini corrado.gioannini at nekhem.com
Mon Mar 11 12:29:33 EST 2002


On Mon, Mar 11, 2002 at 02:06:51PM -0300, Alves, Carlos Alberto - Coelce wrote:
> second code:
> 
> 	def exe1(f,list):
> 		return map(lambda x:eval(f),list)
> 
> Can someone explain to me why the first code works while second doesn't.
try this:

def exe1(f, list):
    return map(lambda x, y=f: eval(y), list)

cheers,
Corrado
-- 
Corrado Gioannini
<corrado.gioannini at nekhem.com>

Nekhem Technologies
Tel.: (+39) 011 4407581

-
"Thought is only a flash between two long nights,
                                         but this flash is everything."
                                                          (H. Poincaré)




More information about the Python-list mailing list