読者です 読者をやめる 読者になる 読者になる

object.__getattr__


>>> class Spam(object):
 def __getattr__(self, name):
     return super(Spam, self).__getattr__(name)

>>> Spam().egg

Traceback (most recent call last):
  File "<pyshell#5>", line 1, in <module>
    Spam().egg
  File "<pyshell#4>", line 3, in __getattr__
    return super(Spam, self).__getattr__(name)
AttributeError: 'super' object has no attribute '__getattr__'

>>> object.__getattr__

Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    object.__getattr__
AttributeError: type object 'object' has no attribute '__getattr__'


アレー!?objectって__getattr__持ってないんですか!?
じゃあ、super(Class, self).__getattr__(name)って、やっちゃダメ!?