Georg Brandl <ge...@python.org> 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 hood" (in 2.x, they were implemented like a simple for loop). Because inner functions need to know what names to get from what enclosing namespace, the names referenced in eval() can't come from enclosing functions. They must either be locals or globals. Of course, the question to the OP is why eval() is needed anyway. ---------- nosy: +georg.brandl resolution: -> wont fix status: open -> pending _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue5242> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com