Message71235
LibRef/built-in functions/eval() has this section
This function can also be used to execute arbitrary code objects (such
as those created by compile()).
In this case pass a code object instead of a string.
The code object must have been compiled passing 'eval' as the kind argument.
As pointed out by Patrick Maupin on py-dev today, the first and third
statements are contradictory: 'arbitrary' != 'limited to kind "eval"'
and the third is wrong in 2.5. It is still wrong in 3.0b2:
>>> eval(compile('1+2', '', 'eval'))
3
>>> eval(compile('1+2', '', 'exec')) # runs and returns None
Because of the first line, I assume this is intended.
Patrick suggests that the third line be expanded to
In order to return a result other than None to eval's caller, the code
object must have been compiled passing 'eval' as the kind argument.
I prefer the slightly more compact
In order for eval to return a result other than None, the code object
must have been compiled passing 'eval' as the kind argument.
or even
However eval will return None unless the code object was compiled with
'eval' as the kind argument. |
|
Date |
User |
Action |
Args |
2008-08-16 20:39:48 | terry.reedy | set | recipients:
+ terry.reedy, georg.brandl |
2008-08-16 20:39:47 | terry.reedy | set | messageid: <1218919187.91.0.149398237755.issue3569@psf.upfronthosting.co.za> |
2008-08-16 20:39:47 | terry.reedy | link | issue3569 messages |
2008-08-16 20:39:45 | terry.reedy | create | |
|