Python __getattr__ And __name__
I'm using 'new style' classes in Python 2.6 and am having trouble with __getattr__ in a subclass. If the subclass implements like such... def __getattr__(self, name): if self._
Solution 1:
__name__
is predefined for class objects, not instances, and you don't define __name__
anywhere before trying to read it. So _getattr__
is called (since __name__
can't be found via normal lookup) and results in an exception. I suspect that what you actually want is:
...
def printName(self):
Base.printMsg('#', self.__class__.__name__)
return
...
Post a Comment for "Python __getattr__ And __name__"