variable hell

Robert Kern rkern at ucsd.edu
Thu Aug 25 16:23:02 EDT 2005


rafi wrote:

> In the meantime another question I cannot find an answer to: any idea 
> why does eval() consider '=' as a syntax error?
> 
>  >>> eval ('a=1')
> Traceback (most recent call last):
>    File "<stdin>", line 1, in ?
>    File "<string>", line 1
>      a=1
>       ^
> SyntaxError: invalid syntax

eval *evaluates* an expression. "a=1" is a statement. It has no value.

-- 
Robert Kern
rkern at ucsd.edu

"In the fields of hell where the grass grows high
 Are the graves of dreams allowed to die."
  -- Richard Harter




More information about the Python-list mailing list