<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Nov 13, 2014 at 2:20 AM, Gregory Ewing <span dir="ltr"><<a href="mailto:greg.ewing@canterbury.ac.nz" target="_blank">greg.ewing@canterbury.ac.nz</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Fabio Zadrozny wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
can someone from python-dev give some background of why that's the way it is?<br>
</blockquote>
<br></span>
It's because, with new-style classes, a class is also an<br>
instance (of class "type" or a subclass thereof). So<br>
without that rule, it would be ambiguous whether a dunder<br>
method applied to instances of a class or to the class<br>
itself.<span class=""><br>
<br>
> and if maybe it's something which python-dev would consider worth<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
changing in the future -- not sure how much could break because of that though<br>
</blockquote>
<br></span>
Something fairly fundamental that would break is classs<br>
instantiation! You instantiate a class by calling it, so if<br>
a(x) were implemented as a.__call__(x), and class C had<br>
a __call__ method, then C() would invoke that method<br>
instead of instantiating C.<div class="HOEnZb"><div class="h5"><br></div></div></blockquote><div><br></div><div>Hi Gregory,</div><div><br></div><div>Thanks for the explanation -- it still does seem a bit surprising from an end-user point of view, but it does make more sense now :) </div><div><br></div><div>Best Regards,</div><div><br></div><div>Fabio</div></div></div></div>