title: Understanding Python Descriptors
body: <p>I am trying to understand descriptors better.</p>
  
  <p>I don't understand why in the foo method the descriptors <em><code>__get__</code></em> method doesn't get called.</p>
  
  <p>As far as I understand descriptors the <em><code>__get__</code></em> method always get called when I access the objects attribute via dot operator or when I use <code>__getattribute__()</code>.</p>
  
  <p>According to the <a href="https://docs.python.org/2/howto/descriptor.html#descriptor-protocol" rel="nofollow noreferrer">Python documentation</a>:</p>
  
  <pre><code>class RevealAccess(object):
      def __init__(self, initval=None, name='var'):
          self.val = initval
          self.name = name
  
      def __get__(self, obj, objtype):
          print('Retrieving', self.name)
          return self.val
  
      def __set__(self, obj, val):
          print('Updating', self.name)
          self.val = val
  
  class MyClass(object):
      x = RevealAccess(10, 'var "x"')
      y = 5
  
      def foo(self):
          self.z = RevealAccess(13, 'var "z"')
          self.__getattribute__('z')
          print(self.z)
  
  m = MyClass()
  m.foo()
  m.z # no print
  m.x # prints var x
  </code></pre>