title: How to prevent AttributeError for undeclared variables and methods and fix __getattr__ method call multiple times?
body: <pre><code>class Foo(object):
       def __init__(self):
           self.a = 1
           self.c = 0
       def __getattr__(self, name):
           self.c += 1
           print('getattribute')
           if hasattr(self, name) is False:
               print("No")
               return None
           return super(Foo, self).__getattr__(self, name)
  
  fo = Foo()
  print(fo.a)
  print(fo.b)
  print(fo.c)
  </code></pre>
  
  <p>Running the above programs prints "getattribute" and "no" multiple times. <code>__getattr__</code> is called multiple times. 333 to be exact. <code>self.c</code> prints 333.</p>
  
  <p>What I want to achieve is to have a class that doesn't raise an error if a class variable or method is not declared in the class.</p>
  
  <p>Whats the possible reason for this?</p>