class test:
a="hi"
def msg(self):
print the variable for which the object is referring to
t= test()
print t.b
From the above code is there any way to tell that the object is referring to a variable b which does not exist
Use the
__getattr__method, see documentation:EDIT:
EDIT2: