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

2009-02-14 Thread Georg Brandl
Georg Brandl added the comment: I agree. -- status: pending -> closed ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubsc

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

2009-02-13 Thread Ezio Melotti
Ezio Melotti added the comment: eval() is probably already an hack, there's no need to add another hack to make it work. It's better to just get rid of eval() and find a better way to do what you want to do. ___ Python tracker

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

2009-02-13 Thread Tim Gordon
Tim Gordon added the comment: If you know what variable you are going to be eval-ing, or at least, have a list of those that might be eval-ed, you can get around this issue by making sure they are explicitly referenced in the inner scope (i.e., in the list comprehension). For example, even t

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

2009-02-13 Thread Georg Brandl
Georg Brandl added the comment: Ezio: this happens inside a function, like this: def f(): canBusType = 'CANdiag' result = [eval('canBusType') for i in range(3)] This is expected, and won't easily fix. The reason is that list comprehensions in 3.x use a function namespace "under the ho

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

2009-02-13 Thread Jiafei Peng
egistergericht/Registration Court: Amtsgericht Charlottenburg Registernummer/Company Registration Number: HRB 21 280 Geschäftsführer/Managing Directors: Kurt Blumenröder, Michael Schubert Ezio Melotti 13.02.2009 11:04 Bitte antworten an Python tracker An jiafei.p...@iav.de Kopie Thema [issue5242

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

2009-02-13 Thread Jiafei Peng
afei.p...@iav.de Kopie Thema [issue5242] eval() function in List Comprehension doesn't work Hagen Fürstenau added the comment: I can't reproduce this. For me it works as expected. -- nosy: +hagen ___ Python tracker <htt

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

2009-02-13 Thread Ezio Melotti
Ezio Melotti 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

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

2009-02-13 Thread Hagen Fürstenau
Hagen Fürstenau added the comment: I can't reproduce this. For me it works as expected. -- nosy: +hagen ___ Python tracker ___ ___ Pyt

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

2009-02-13 Thread Jiafei Peng
New submission from Jiafei Peng : eval() function in List Comprehension doesn't work. please see the under codes: canBusType = 'CANdiag' result = [eval('canBusType') for i in range(3)] NameError: name 'canBusType' is not defined It did work in Python2.5 or 2.6. The expected result is ['CANdiag