You can do something like this: >>> class A(): pass >>> inst=A() >>> exec(""" ... a=1 ... 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 -- http://mail.python.org/mailman/listinfo/python-list