[Tutor] [Fwd: [Fwd: self-modification]]

Kent Johnson kent37 at tds.net
Tue Aug 22 13:22:09 CEST 2006


Zsiros Levente wrote:
> Why does the python shell says this:
>
>   
>>>> print exec.__doc__
>>>>         
>   File "<stdin>", line 1
>     print exec.__doc__
>              ^
> SyntaxError: invalid syntax
>
>
> While it works with "eval".

exec is a statement that is interpreted by the compiler and compiled to 
byte code. There is no 'exec' object. OTOH eval is a function in the 
built-in namespace, so there is an 'eval' object and you can look at its 
attributes, including its doc string.

Kent



More information about the Tutor mailing list