<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=ISO-8859-1">
<META NAME="Generator" CONTENT="MS Exchange Server version 5.5.2653.12">
<TITLE>ENC: lambda question</TITLE>
</HEAD>
<BODY>

<P><FONT SIZE=2>See the error below:</FONT>
</P>

<P><FONT SIZE=2>>>> def exe1(f,list):</FONT>
<BR>        <FONT SIZE=2>return map(lambda x:eval(f),list)</FONT>
<BR><FONT SIZE=2>SyntaxError: local name 'f' in 'exe1' shadows use of 'f' as global in nested scope 'lambda' (<pyshell#7>, line 1)</FONT>
<BR><FONT SIZE=2>>>> </FONT>
</P>
<BR>

<P><FONT SIZE=2>> -----Mensagem original-----</FONT>
<BR><FONT SIZE=2>> De: Bertrand Geston [<A HREF="mailto:bergeston@yahoo.fr">mailto:bergeston@yahoo.fr</A>] </FONT>
<BR><FONT SIZE=2>> Enviada em: segunda-feira, 11 de março de 2002 14:46</FONT>
<BR><FONT SIZE=2>> Para: python-list@python.org</FONT>
<BR><FONT SIZE=2>> Assunto: Re: lambda question</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> lambda questionBoth work on my computer:</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> PythonWin 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit </FONT>
<BR><FONT SIZE=2>> (Intel)] on win32.</FONT>
<BR><FONT SIZE=2>> Portions Copyright 1994-2001 Mark Hammond </FONT>
<BR><FONT SIZE=2>> (mhammond@skippinet.com.au) - see</FONT>
<BR><FONT SIZE=2>> 'Help/About PythonWin' for further copyright information.</FONT>
<BR><FONT SIZE=2>> >>> def exe1(f,list):</FONT>
<BR><FONT SIZE=2>> ...  return map(lambda x:eval(f),list)</FONT>
<BR><FONT SIZE=2>> ...</FONT>
<BR><FONT SIZE=2>> >>> f='x**3+2*x'</FONT>
<BR><FONT SIZE=2>> >>> list=[0,1,2,0]</FONT>
<BR><FONT SIZE=2>> >>> map(lambda x:eval(f),list)</FONT>
<BR><FONT SIZE=2>> [0, 3, 12, 0]</FONT>
<BR><FONT SIZE=2>> >>> exe1(f,list)</FONT>
<BR><FONT SIZE=2>> [0, 3, 12, 0]</FONT>
<BR><FONT SIZE=2>> >>></FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> If you give us the kind of error, problem hou have, you will </FONT>
<BR><FONT SIZE=2>> help us to help</FONT>
<BR><FONT SIZE=2>> you.</FONT>
<BR><FONT SIZE=2>> TIA ;-)</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> "Alves, Carlos Alberto - Coelce" <calves@coelce.com.br> wrote </FONT>
<BR><FONT SIZE=2>> in message</FONT>
<BR><FONT SIZE=2>> <A HREF="news:mailman.1015866267.21439.python-list@python.org" TARGET="_blank">news:mailman.1015866267.21439.python-list@python.org</A>...</FONT>
<BR><FONT SIZE=2>> Hi all,</FONT>
<BR><FONT SIZE=2>> Look at the two codes below</FONT>
<BR><FONT SIZE=2>> first code:</FONT>
<BR><FONT SIZE=2>>         f='x**3+2*x'</FONT>
<BR><FONT SIZE=2>>         list=[0,1,2,0]</FONT>
<BR><FONT SIZE=2>>         map(lambda x:eval(f),list)</FONT>
<BR><FONT SIZE=2>> second code:</FONT>
<BR><FONT SIZE=2>>         def exe1(f,list):</FONT>
<BR><FONT SIZE=2>>                 return map(lambda x:eval(f),list)</FONT>
<BR><FONT SIZE=2>> Can someone explain to me why the first code works while </FONT>
<BR><FONT SIZE=2>> second doesn't.</FONT>
<BR><FONT SIZE=2>> Carlos Alberto</FONT>
<BR><FONT SIZE=2>> COELCE/DPRON-Departamento de Projetos e Obras Norte</FONT>
<BR><FONT SIZE=2>> Fone: 677- 2228</FONT>
<BR><FONT SIZE=2>> e-mail: calves@coelce.com.br</FONT>
<BR><FONT SIZE=2>> \|||/</FONT>
<BR><FONT SIZE=2>> (o o)</FONT>
<BR><FONT SIZE=2>> --ooo0-(_)-0ooo--</FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> </FONT>
<BR><FONT SIZE=2>> -- </FONT>
<BR><FONT SIZE=2>> <A HREF="http://mail.python.org/mailman/listinfo/python-list" TARGET="_blank">http://mail.python.org/mailman/listinfo/python-list</A></FONT>
<BR><FONT SIZE=2>> </FONT>
</P>

</BODY>
</HTML>