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.
--
--
http://mail.python.org/mailman/listinfo/python-list