BJörn Lindqvist <[EMAIL PROTECTED]> wrote: >I think it would be cool if you could refer to instance variables >without prefixing with "self." I know noone else thinks like me so >Python will never be changed, but maybe you can already do it with >Python today? > >.import sys >. >.def magic(): >. s = "" >. for var in sys._getframe(1).f_locals["self"].__dict__: >. s += var + " = self." + var + "\n" >. return s >. >.class A: >. def __init__(self): >. self.hi = "yo" >. >. def meth(self): >. exec(magic()) >. print hi >. >.a = A() >.a.meth() > >It works! exec(magic()) does the needed hi = self.hi.
Does it? class A: def __init__(self): self.hi = "yo" def meth(self): exec(magic()) print hi hi = "baby" print hi def other(self): exec(magic()) print hi a = A() a.meth() a.other() That's way too fragile to be useful. -- - Tim Roberts, [EMAIL PROTECTED] Providenza & Boekelheide, Inc. -- http://mail.python.org/mailman/listinfo/python-list