lambda question

Bertrand Geston bergeston at yahoo.fr
Mon Mar 11 12:46:10 EST 2002


lambda questionBoth work on my computer:

PythonWin 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32.
Portions Copyright 1994-2001 Mark Hammond (mhammond at skippinet.com.au) - see
'Help/About PythonWin' for further copyright information.
>>> def exe1(f,list):
...  return map(lambda x:eval(f),list)
...
>>> f='x**3+2*x'
>>> list=[0,1,2,0]
>>> map(lambda x:eval(f),list)
[0, 3, 12, 0]
>>> exe1(f,list)
[0, 3, 12, 0]
>>>

If you give us the kind of error, problem hou have, you will help us to help
you.
TIA ;-)

"Alves, Carlos Alberto - Coelce" <calves at coelce.com.br> wrote in message
news:mailman.1015866267.21439.python-list at python.org...
Hi all,
Look at the two codes below
first code:
        f='x**3+2*x'
        list=[0,1,2,0]
        map(lambda x:eval(f),list)
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.
Carlos Alberto
COELCE/DPRON-Departamento de Projetos e Obras Norte
Fone: 677- 2228
e-mail: calves at coelce.com.br
\|||/
(o o)
--ooo0-(_)-0ooo--





More information about the Python-list mailing list