Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.albasani.net!news.stack.nl!newsfeed.xs4all.nl!newsfeed1.news.xs4all.nl!xs4all!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.008 X-Spam-Evidence: '*H*': 0.98; '*S*': 0.00; 'subject:: [': 0.04; 'subject:Python': 0.06; 'lookup': 0.09; 'subject:method': 0.09; 'subject:set': 0.09; 'bind': 0.16; 'callable.': 0.16; 'descriptor': 0.16; 'evaluating': 0.16; 'invoking': 0.16; 'subject:Dev': 0.16; 'sat,': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'header:In-Reply-To:1': 0.27; "doesn't": 0.30; 'message- id:@mail.gmail.com': 0.30; "i'm": 0.30; 'class': 0.32; 'actual': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'method': 0.36; 'nov': 0.38; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'skip:t 30': 0.61; 'course': 0.61; 'more': 0.64; '"look': 0.84; 'technique': 0.93 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 :content-type; bh=uyBV1cZQeyB+9/M7BO+4WKDe3p3OUrr1Y9C/GhtgPnk=; b=SSx3GsnAO9xynU6xyDmRs3BYkr5VMvVW7340qRRnKfDazhn1nVxSSCF1SXgxjWzyM+ tLg7IvGrj/481xO57Jw2mP2xMtsy9bL91t/jG2naQBQzyiPGahr1ulThcorEAcGPvSob 2/wSL7kGOEu0lPQkhewifGjWoQ8UcRLh0zOYlYtpdLij0XneBzOLo3AzHST+kKX9jfta M0hdwKf9dpV1Y4L1wTf8t3ecbF37ss+jMe7khpo8N4oyAVFoYk/ffy9Sc7TzuJCI65mh LHN17UxAtQv4nKeSzYinQt6QXzh1U06I7IqChxdtU3ryo3/YN4z91lhuxvvmx4ZjYZN8 Rn2A== X-Received: by 10.68.65.37 with SMTP id u5mr38889976pbs.24.1415691860943; Mon, 10 Nov 2014 23:44:20 -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: Ian Kelly Date: Tue, 11 Nov 2014 00:43:40 -0700 Subject: Re: [Python-Dev] Dinamically set __call__ method To: Python Content-Type: text/plain; charset=UTF-8 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: 12 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415691870 news.xs4all.nl 2960 [2001:888:2000:d::a6]:42668 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80505 On Sat, Nov 8, 2014 at 3:31 PM, Gregory Ewing wrote: > (BTW, I'm actually surprised that this technique makes c callable. > There must be more going on that just "look up __call__ in the class > object", because evaluating C.__call__ just returns the descriptor > and doesn't invoking the descriptor mechanism.) But of course it doesn't just lookup C.__call__, because it has to bind the method to the instance before calling it, which means invoking the descriptor protocol. The actual lookup is more like: type(a).__dict__['__call__'].__get__(a, type(a))