Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!ecngs!feeder2.ecngs.de!novso.com!newsfeed.xs4all.nl!newsfeed4.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; 'classes,': 0.05; 'subject:Python': 0.06; '(of': 0.07; 'explanation': 0.09; 'method,': 0.09; 'subject:method': 0.09; 'subject:set': 0.09; 'cc:addr:python-list': 0.11; 'itself.': 0.14; 'cc:name:python list': 0.16; 'fabio': 0.16; 'new-style': 0.16; 'subclass': 0.16; 'subject:Dev': 0.16; 'surprising': 0.16; 'wrote:': 0.18; 'bit': 0.19; 'thu,': 0.19; 'subject:] ': 0.20; 'cc:addr:python.org': 0.22; 'fairly': 0.24; 'cc:2**0': 0.24; '>': 0.26; 'header:In-Reply-To:1': 0.27; 'point': 0.28; 'am,': 0.29; 'is?': 0.30; 'message-id:@mail.gmail.com': 0.30; '13,': 0.31; 'invoke': 0.31; 'class': 0.32; 'implemented': 0.33; 'sense': 0.34; 'maybe': 0.34; 'could': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'instances': 0.36; 'view,': 0.36; 'method': 0.36; 'thanks': 0.36; 'changing': 0.37; 'skip:& 10': 0.38; 'nov': 0.38; 'does': 0.39; 'sure': 0.39; 'how': 0.40; 'future': 0.60; 'break': 0.61; 'more': 0.64; 'worth': 0.66; 'ambiguous': 0.84; 'end-user': 0.84; 'gregory,': 0.84; 'python- dev': 0.84 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=4mmprcTGVznEXPU88dDtgz3qu6Ir2TT/Dr6IhlO8Lf4=; b=Jc3g/zqFWeb8cC85ipaU8HTA18i6Vv7wuLYE8OBnY41GBq12NeGU/3vabIbXIDkJ8W 4DXMqS1Py1pOjwzRJ8T+BhaTmtacWR35evEIyqantLff98CCrklV2K8xY0y2u7KZPOEl U2HVyo//VZSCYqgLpZ8UlhZKnANvAxgbjhmapRjF/yW1AxpnxXERYtDr6a/MG0LDAaGU /tby3s381a6HQqMKD063zjsBt4eM/R4mdyeIt3roSg1tnQi5/QNa1Qyzq+gAnH/4wYY1 U9fBTDc6KXn8GlaIiytBojrh3YtNsi7AyUiVbFpVUct136AbUalU2wk057znvlAqRGFy RG0w== X-Received: by 10.194.205.132 with SMTP id lg4mr4077694wjc.84.1415885957242; Thu, 13 Nov 2014 05:39:17 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <545919B6.7040007@stoneleaf.us> <87a943qyvn.fsf@handshake.de> <545CC204.2010301@stoneleaf.us> <8761eq424e.fsf@handshake.de> From: Fabio Zadrozny Date: Thu, 13 Nov 2014 11:38:57 -0200 Subject: Re: [Python-Dev] Dinamically set __call__ method To: Gregory Ewing Content-Type: multipart/alternative; boundary=047d7bb709428629bc0507bda3ec Cc: python list X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 82 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415885965 news.xs4all.nl 2977 [2001:888:2000:d::a6]:45866 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80684 --047d7bb709428629bc0507bda3ec Content-Type: text/plain; charset=UTF-8 On Thu, Nov 13, 2014 at 2:20 AM, Gregory Ewing wrote: > Fabio Zadrozny wrote: > >> can someone from python-dev give some background of why that's the way it >> is? >> > > It's because, with new-style classes, a class is also an > instance (of class "type" or a subclass thereof). So > without that rule, it would be ambiguous whether a dunder > method applied to instances of a class or to the class > itself. > > > 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 >> > > Something fairly fundamental that would break is classs > instantiation! You instantiate a class by calling it, so if > a(x) were implemented as a.__call__(x), and class C had > a __call__ method, then C() would invoke that method > instead of instantiating C. > > Hi Gregory, 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 :) Best Regards, Fabio --047d7bb709428629bc0507bda3ec Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable

= On Thu, Nov 13, 2014 at 2:20 AM, Gregory Ewing <greg.ewing@cante= rbury.ac.nz> wrote:
Fabio Zadrozny wrote:
can someone from python-dev give some background of why that's the way = it is?

It's because, with new-style classes, a class is also an
instance (of class "type" or a subclass thereof). So
without that rule, it would be ambiguous whether a dunder
method applied to instances of a class or to the class
itself.

> and if maybe it's something which python-dev would consider worth<= br>
changing in the future -- not sure how much could break because of that tho= ugh

Something fairly fundamental that would break is classs
instantiation! You instantiate a class by calling it, so if
a(x) were implemented as a.__call__(x), and class C had
a __call__ method, then C() would invoke that method
instead of instantiating C.


Hi Gregory,

Thanks for the explanation -- it still does seem a bit surprising from a= n end-user point of view, but it does make more sense now :)=C2=A0

Best Regards,

Fabio
--047d7bb709428629bc0507bda3ec--