<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Nov 11, 2014 at 5:43 AM, Ian Kelly <span dir="ltr"><<a href="mailto:ian.g.kelly@gmail.com" target="_blank">ian.g.kelly@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><span class="">On Sat, Nov 8, 2014 at 3:31 PM, Gregory Ewing<br>
<<a href="mailto:greg.ewing@canterbury.ac.nz">greg.ewing@canterbury.ac.nz</a>> wrote:<br>
> (BTW, I'm actually surprised that this technique makes c callable.<br>
> There must be more going on that just "look up __call__ in the class<br>
> object", because evaluating C.__call__ just returns the descriptor<br>
> and doesn't invoking the descriptor mechanism.)<br>
<br>
</span>But of course it doesn't just lookup C.__call__, because it has to<br>
bind the method to the instance before calling it, which means<br>
invoking the descriptor protocol. The actual lookup is more like:<br>
<br>
type(a).__dict__['__call__'].__get__(a, type(a))<br>
<span class=""><font color="#888888">--<br>
<a href="https://mail.python.org/mailman/listinfo/python-list" target="_blank">https://mail.python.org/mailman/listinfo/python-list</a><br>
</font></span></blockquote></div><br></div><div class="gmail_extra"><br></div><div class="gmail_extra">As a reference, I recently found a blog post related to that: <a href="http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/">http://lucumr.pocoo.org/2014/8/16/the-python-i-would-like-to-see/</a> (the Slots part comments on that).</div><div class="gmail_extra"><br></div><div class="gmail_extra">It does seem a bit counter-intuitive that this happens the way it does though, so, can someone from python-dev give some background of why that's the way it is? i.e.: instead of the approach which would seem simpler which would do getattr(a, '__call__') instead of type(a).__dict__['__call__'].__get__(a, type(a)) -- it seems to me it's mostly because of historical reasons, but I'm really curious why is it so (and if maybe it's something which python-dev would consider worth changing in the future -- not sure how much could break because of that though).</div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks and Best Regards,</div><div class="gmail_extra"><br></div><div class="gmail_extra">Fabio</div></div>