eval or execute, is this the (most) correct way ?
Stef Mientki
stef.mientki at gmail.com
Mon Aug 11 11:26:56 EDT 2008
hello,
I'm trying to make an editor with an integrated Shell.
>>So when type:
2+5
>>I want the answer on the next line:
7
>>When I type:
myvar = 55
myvar
>>I want the value of myvar:
55
So AFAIK, sometimes I've to use eval and sometimes I need exec,
so I use the following code (global / local dictionary parameters are
left out in this example):
try:
print eval ( line )
except :
exec ( line )
Is this the (most) correct / elegant way, or are there better solutions ?
I read somewhere that exec is going to disappear,
and noticed that in 2.5 (I just updated to) the doc is already disapeared,
is this no longer possible in Python 3 ?
thanks,
Stef Mientki
More information about the Python-list
mailing list