This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author georg.brandl
Recipients JiafeiPeng, ezio.melotti, georg.brandl, hagen
Date 2009-02-13.10:16:03
SpamBayes Score 3.5149426e-07
Marked as misclassified No
Message-id <1234520164.79.0.148440888366.issue5242@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2009-02-13 10:16:04georg.brandlsetrecipients: + georg.brandl, ezio.melotti, hagen, JiafeiPeng
2009-02-13 10:16:04georg.brandlsetmessageid: <1234520164.79.0.148440888366.issue5242@psf.upfronthosting.co.za>
2009-02-13 10:16:03georg.brandllinkissue5242 messages
2009-02-13 10:16:03georg.brandlcreate