Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!us.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Gregory Ewing Newsgroups: comp.lang.python Subject: Re: [Python-Dev] Dinamically set __call__ method Date: Thu, 13 Nov 2014 17:20:22 +1300 Lines: 22 Message-ID: References: <545919B6.7040007@stoneleaf.us> <87a943qyvn.fsf@handshake.de> <545CC204.2010301@stoneleaf.us> <8761eq424e.fsf@handshake.de> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Trace: individual.net 9IYOiOga7zIYtk4m4IPh8QXfzeZzWSDVffB7fi7yFICTvOBVIx Cancel-Lock: sha1:iewVcUYfz5jAkjNXbY778FuWJmw= User-Agent: Mozilla Thunderbird 1.0.5 (Macintosh/20050711) X-Accept-Language: en-us, en In-Reply-To: Xref: csiph.com comp.lang.python:80667 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. -- Greg