Jiafei Peng <jiafei.p...@iav.de> added the comment:

Yes
it does work properly outside listcomps.

            canBusType = 'CANdiag'
            result1 = eval('canBusType')
            result2 = [eval('canBusType'), eval('canBusType'), eval(
'canBusType')]
            result3 = [eval('canBusType') for i in range(3)]

result1 = 'CANdiag'
result2 =['CANdiag' 'CANdiag' 'CANdiag']
for result3:
NameError: name 'canBusType' is not defined

Best regards, mit freundlichen Grüßen,

Jiafei Peng

Softwareentwickler / Embedded System Software (EF-F2)
Software developer / Embedded System Software 

IAV GmbH
Nordhoffstr. 5
38518 Gifhorn
GERMANY

Phone: +49 5371  805-2817
Fax:+49 5371  805-1330

E-mail:  <mailto:jiafei.p...@iav.de>
Internet: http://www.iav.de

IAV GmbH
Sitz/Registered Office: Berlin
Registergericht/Registration Court: Amtsgericht Charlottenburg
Registernummer/Company Registration Number: HRB 21 280
Geschäftsführer/Managing Directors: Kurt Blumenröder, Michael Schubert

Ezio Melotti <rep...@bugs.python.org> 
13.02.2009 11:04
Bitte antworten an
Python tracker <rep...@bugs.python.org>

An
jiafei.p...@iav.de
Kopie

Thema
[issue5242] eval() function in List Comprehension doesn't work 

Ezio Melotti <ezio.melo...@gmail.com> added the comment:

I can't reproduce it either, tested with Py3 (on Linux and Windows) and
with Py2.[456], it worked fine everywhere.

Does your eval() work properly outside listcomps?

----------
nosy: +ezio.melotti

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5242>
_______________________________________

Added file: http://bugs.python.org/file13066/unnamed

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue5242>
_______________________________________
<br><font size=2 face="sans-serif">Yes</font>
<br><font size=2 face="sans-serif">it does work properly outside 
</font><tt><font size=2>listcomps</font></tt><font size=2 
face="sans-serif">.</font>
<br>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; canBusType = </font><font size=2 color=#00a000 face="Courier 
New"><i>'CANdiag'</i></font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; result1 = eval(</font><font size=2 color=#00a000 face="Courier 
New"><i>'canBusType'</i></font><font size=2 face="Courier New">)</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; result2 = [eval(</font><font size=2 color=#00a000 face="Courier 
New"><i>'canBusType'</i></font><font size=2 face="Courier New">),
eval(</font><font size=2 color=#00a000 face="Courier 
New"><i>'canBusType'</i></font><font size=2 face="Courier New">),
eval(</font><font size=2 color=#00a000 face="Courier 
New"><i>'canBusType'</i></font><font size=2 face="Courier New">)]</font>
<br><font size=2 face="Courier New">&nbsp; &nbsp; &nbsp; &nbsp; &nbsp;
&nbsp; result3 = [eval(</font><font size=2 color=#00a000 face="Courier 
New"><i>'canBusType'</i></font><font size=2 face="Courier New">)
</font><font size=2 color=blue face="Courier New">for</font><font size=2 
face="Courier New">
i </font><font size=2 color=blue face="Courier New">in</font><font size=2 
face="Courier New">
range(</font><font size=2 color=#800000 face="Courier New">3</font><font size=2 
face="Courier New">)]</font>
<br>
<br><font size=2 face="sans-serif">result1 = </font><font size=2 color=#00a000 
face="Courier New"><i>'CANdiag'</i></font>
<br><font size=2 face="sans-serif">result2 =</font><font size=2 color=#00a000 
face="Courier New"><i>['CANdiag'
'CANdiag' 'CANdiag']</i></font>
<br><font size=2 face="sans-serif">for result3:</font>
<br><font size=2 color=red face="Courier New">NameError: name 'canBusType'
is not defined</font>
<br>
<br>
<br><font size=2 face="sans-serif">Best regards, mit freundlichen Grüßen,<br>
<br>
Jiafei Peng<br>
<br>
Softwareentwickler / Embedded System Software (EF-F2)<br>
Software developer / Embedded System Software <br>
<br>
IAV GmbH<br>
Nordhoffstr. 5<br>
38518 Gifhorn<br>
GERMANY<br>
<br>
Phone: +49 5371 &nbsp;805-2817<br>
Fax:+49 5371 &nbsp;805-1330<br>
<br>
E-mail: &nbsp;&lt;mailto:jiafei.p...@iav.de&gt;<br>
Internet: http://www.iav.de<br>
<br>
IAV GmbH<br>
Sitz/Registered Office: Berlin<br>
Registergericht/Registration Court: Amtsgericht Charlottenburg<br>
Registernummer/Company Registration Number: HRB 21 280<br>
Geschäftsführer/Managing Directors: Kurt Blumenröder, Michael Schubert<br>
 </font>
<br>
<br>
<br>
<table width=100%>
<tr valign=top>
<td width=40%><font size=1 face="sans-serif"><b>Ezio Melotti 
&lt;rep...@bugs.python.org&gt;</b>
</font>
<p><font size=1 face="sans-serif">13.02.2009 11:04</font>
<table border>
<tr valign=top>
<td bgcolor=white>
<div align=center><font size=1 face="sans-serif">Bitte antworten an<br>
Python tracker &lt;rep...@bugs.python.org&gt;</font></div></table>
<br>
<td width=59%>
<table width=100%>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">An</font></div>
<td><font size=1 face="sans-serif">jiafei.p...@iav.de</font>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Kopie</font></div>
<td>
<tr valign=top>
<td>
<div align=right><font size=1 face="sans-serif">Thema</font></div>
<td><font size=1 face="sans-serif">[issue5242] eval() function in List
Comprehension doesn't work</font><font size=2 face="sans-serif"> </font></table>
<br>
<table>
<tr valign=top>
<td>
<td></table>
<br></table>
<br>
<br>
<br><tt><font size=2><br>
Ezio Melotti &lt;ezio.melo...@gmail.com&gt; added the comment:<br>
<br>
I can't reproduce it either, tested with Py3 (on Linux and Windows) and<br>
with Py2.[456], it worked fine everywhere.<br>
<br>
Does your eval() work properly outside listcomps?<br>
<br>
----------<br>
nosy: +ezio.melotti<br>
<br>
_______________________________________<br>
Python tracker &lt;rep...@bugs.python.org&gt;<br>
&lt;http://bugs.python.org/issue5242&gt;<br>
_______________________________________<br>
</font></tt>
<br>
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to