Andreas Löscher wrote:
You can do something like this:
class A(): pass
inst=)
exec("""
... a=
... b=2
... c=3
... d=4
... """) in inst.__dict__
inst.a
1
This executes the Statement in the exec function and uses inst.__dict__
as namespace. But be aware, that this is not recommended. If you mess
with __dict__, you won't be able to replace it with some logic
(parameter) if you need to do something more than setting a variable.
Best
Hi Andreas, thanks for the reply,
Looks like I'll be sticking with repeating the class-name for a while.
Regards,
Alan
--
http://mail.python.org/mailman/listinfo/python-list