python eval function

Ned Batchelder ned at nedbatchelder.com
Sun Aug 25 20:25:17 EDT 2013


On 8/25/13 7:49 PM, Terry Reedy wrote:
> On 8/25/2013 3:18 PM, Mohsen Pahlevanzadeh wrote:
>
>> eval doesn't run my code at the following link:
>> http://stackoverflow.com/questions/18432198/eval-function-doesnt-work-in-python 
>>
>
> Already answered there (code is statememt, not expression)
>
The larger issue is that your use of eval seems unnecessary.  If you are 
trying to set variable variable names, you probably want a dict instead.

Oh, and get rid of the semicolons at the ends of lines, they are 
unnecessary and a sign of old habits from another programming language.

--Ned.




More information about the Python-list mailing list