syntax error in eval()

harold fellermann harold.fellermann at
Mon Jan 10 12:05:46 EST 2005

Thank you, Duncan and Steven.
I completely forgot about setattr.
Of course that's the way ... as its name might suggest *g*

> What you are doing wrong is attempting to use eval before exhausting 
> all
> the simpler techniques. Why not just call 'setattr'?
>>>> setattr(X, 'attr', 5)
> BTW, the syntax error is because eval evaluates an expression and
> an assignment statement is a statement not an expression.

Abandon the search for Truth -- settle for a good fantasy.

More information about the Python-list mailing list