"Wayne Watson" <[email protected]> wrote
Python doesn't like the code in the Subject (unqualified exec
not allowed in function). but easily likes self.abc="22".
We'd need to see the code and traceback to guess why...
However, I'd like to assemble the assignment as a string,
as shown in Subject, and execute it. Is there a way to do this?
exec is the usual way but it's also usually a bad idea.
Any reason why you want to do that rather than any of
the safer alternatives? (dict, setattr etc)
--
Alan G
Author of the Learn to Program web site
http://www.alan-g.me.uk/
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor