Message81918
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 though list
comprehensions work in 2.x, generator expressions don't, but this hack
does (on 2.4 at least):
def f():
canBusType = 'CANdiag'
return (eval('canBusType') for i in range(3) if True or canBusType)
By putting a semantically vacuous reference to canBusType (and any
other variables you want) you make sure they are usable from within the
eval as well. |
|
Date |
User |
Action |
Args |
2009-02-13 13:01:06 | QuantumTim | set | recipients:
+ QuantumTim, georg.brandl, ezio.melotti, hagen, JiafeiPeng |
2009-02-13 13:01:06 | QuantumTim | set | messageid: <1234530066.22.0.758765755892.issue5242@psf.upfronthosting.co.za> |
2009-02-13 13:01:04 | QuantumTim | link | issue5242 messages |
2009-02-13 13:01:03 | QuantumTim | create | |
|