Understanding the descriptor example from "descriptors howto" article
<p>I am trying to wrap my head around the concept of descriptors and I have had no success lately. This <a href="https://docs.python.org/3/howto/descriptor.html" rel="nofollow noreferrer">article</a> of descriptor How to has really helped and at the same time it has also confused me. I am struggling with this example here
on why <code>m.x</code> calls <code>def __get__(self, obj, objtype):</code></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

&gt;&gt;&gt; class MyClass(object):
...     x = RevealAccess(10, 'var "x"')
...     y = 5
...
&gt;&gt;&gt; m = MyClass()
&gt;&gt;&gt; m.x
Retrieving var "x"
10
</code></pre>

<p>I believe the reason i am struggling with this is because I am confused by the following statement in the article</p>

<blockquote>
  <p>The details of invocation depend on whether obj is an object or a
  class. For objects, the machinery is in <code>object.__getattribute__()</code>
  which transforms <code>b.x</code> into <code>type(b).__dict__['x'].__get__(b, type(b))</code>.
  The implementation works through a precedence chain that gives data
  descriptors priority over instance variables, instance variables
  priority over non-data descriptors, and assigns lowest priority to
  <code>__getattr__()</code> if provided</p>
</blockquote>

<p>I am not sure what the author means here by object or class. Does object mean an instance of a class ? I understand that when we do <code>instance.var</code> python internally does a <code>instance.__dict__["var"]</code> if that is not found then it does <code>class.__dict__["var"]</code>. I kind of lost it after that concept. Could anyone explain a little on how this example is working. How is the definition <code>def __get__(self, obj, objtype):</code> being called with <code>m.x</code>. I would be very grateful if anyone could clear this up.</p>