Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #80395

Re: [Python-Dev] Dinamically set __call__ method

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed2a.news.xs4all.nl!xs4all!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; 'subject:Python': 0.06; 'correct,': 0.09; 'definition,': 0.09; 'function,': 0.09; 'instance.': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'resolved,': 0.09; 'subject:method': 0.09; 'subject:set': 0.09; "wouldn't": 0.14; '+1.': 0.16; '10:59': 0.16; 'descriptor': 0.16; 'factory,': 0.16; 'overriding': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:Dev': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; '>>>': 0.22; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'instance,': 0.24; 'looks': 0.24; 'header:X-Complaints-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'possibility': 0.29; '>>>>': 0.31; 'though.': 0.31; 'writes:': 0.31; 'class': 0.32; 'implemented': 0.33; 'really': 0.36; 'method': 0.36; 'charset:us- ascii': 0.36; 'to:addr:python-list': 0.38; 'pm,': 0.38; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:org': 0.40; 'john': 0.61; 'received:217': 0.63; 'real': 0.63; 'different': 0.65; 'within': 0.65; 'ethan': 0.84; 'furman': 0.84; 'positively': 0.84; 'absolutely': 0.87
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From dieter <dieter@handshake.de>
Subject Re: [Python-Dev] Dinamically set __call__ method
Date Sat, 08 Nov 2014 07:50:41 +0100
References <CAF0TK51TKs+tw=u_rzrWVeSsDK7cOBt1Gcvq_izLfMObuDYNig@mail.gmail.com> <545919B6.7040007@stoneleaf.us> <CAF0TK52vw_SmqexN8RXyGs8GSKecPobK54ZqYPyKgRSSJy9zWw@mail.gmail.com> <mailman.15467.1415128339.18130.python-list@python.org> <c25aa612-bff2-4982-8fb9-5b17a866bead@googlegroups.com> <87a943qyvn.fsf@handshake.de> <545CC204.2010301@stoneleaf.us>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e08af6.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:gy5B1wxOZdx2LdQuvNg3Wo6yfK4=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.15580.1415429455.18130.python-list@python.org> (permalink)
Lines 21
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415429455 news.xs4all.nl 2829 [2001:888:2000:d::a6]:59591
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:80395

Show key headers only | View raw


Ethan Furman <ethan@stoneleaf.us> writes:

> On 11/06/2014 10:59 PM, dieter wrote:
>> John Ladasky writes:
>>> On Tuesday, November 4, 2014 11:12:31 AM UTC-8, Ethan Furman wrote:
>>>
>>>> If you really absolutely positively have to have the signature be correct for each instance, you may to either look at a
>>>> function creating factory, a class creating factory, or a meta-class.
>>>
>>> +1.  Overriding __call__() within the class definition, over and over again, with different function, looks awkward to me.
>>
>> A possibility to get the original approach implemented looks like:
>>
>>    make "__call__" a descriptor on the class which looks up the real
>>    method on the instance.
>
> This still wouldn't get the signatrue correct, though.

Why not? Once the descriptor is resolved, you get the final
instance method - with the correct signature.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-04 11:12 -0800
  Re: [Python-Dev] Dinamically set __call__ method John Ladasky <john_ladasky@sbcglobal.net> - 2014-11-06 12:21 -0800
    Re: [Python-Dev] Dinamically set __call__ method dieter <dieter@handshake.de> - 2014-11-07 07:59 +0100
    Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-07 04:58 -0800
    Re: [Python-Dev] Dinamically set __call__ method dieter <dieter@handshake.de> - 2014-11-08 07:50 +0100
    Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-08 11:49 -0800
      Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-09 11:31 +1300
        Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-08 19:27 -0800
          Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-10 00:38 +1300
            Re: [Python-Dev] Dinamically set __call__ method Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-11-10 00:14 +1100
            Re: [Python-Dev] Dinamically set __call__ method Ethan Furman <ethan@stoneleaf.us> - 2014-11-09 12:16 -0800
        Re: [Python-Dev] Dinamically set __call__ method Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-11 00:43 -0700
        Re: [Python-Dev] Dinamically set __call__ method Fabio Zadrozny <fabiofz@gmail.com> - 2014-11-12 13:33 -0200
          Re: [Python-Dev] Dinamically set __call__ method Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-11-13 17:20 +1300
            Re: [Python-Dev] Dinamically set __call__ method Fabio Zadrozny <fabiofz@gmail.com> - 2014-11-13 11:38 -0200
        Re: [Python-Dev] Dinamically set __call__ method Ian Kelly <ian.g.kelly@gmail.com> - 2014-11-12 11:58 -0700

csiph-web