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


Groups > comp.lang.python > #80219

Re: [Python-Dev] Dinamically set __call__ method

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!bcyclone03.am1.xlned.com!bcyclone03.am1.xlned.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 <skip.montanaro@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.001
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; '-for': 0.05; 'subject:Python': 0.06; '*args,': 0.09; 'subject:method': 0.09; 'subject:set': 0.09; 'cc:addr:python- list': 0.11; 'def': 0.12; '**kwds)': 0.16; '**kwds):': 0.16; 'runtime.': 0.16; 'subject:Dev': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'email addr:gmail.com&gt;': 0.22; 'cc:addr:python.org': 0.22; 'skip': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'cc:2**2': 0.30; 'message-id:@mail.gmail.com': 0.30; 'workaround': 0.31; 'skip:_ 10': 0.34; 'could': 0.34; 'received:google.com': 0.35; 'method': 0.36; 'nov': 0.38; 'pm,': 0.38; 'different': 0.65; 'to:addr:gmail.com': 0.65
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=+ia4lCcpWo/tUQnYxmB5t/DEuCtmRXLptgPmIMcH9Jc=; b=ZNOM851lVJju39zy10JDfl7PbAvASmfMDhVrELz+XH0EBYQ8hzNvx8WxzCkJ2WxIbJ VTnM3/YkB9Ek2Uvnj68pdo7syfJk3Axr/LzTWNqmnlGGGmcB0r+7DbsXDaAkmpLeukhd OsmCDBfnlSFbhYvdP89FZIx6IWDWAWjbA5D8Vn2+VaRD5AghDzuYPhrXz9pZlNPAfQn6 /FN7rA8aGV9EUZ/FcG4v4tvo1Xh8MFuKg6WYXoSPjO66f+S43N6N7VorwAeIleDG1Ygo M9v+S2CINMRpx64rzCsNQPIT3NV3twKPvQe6Bq52RzoJYrXijLC69YjsPdC2pKXN1Hzz 5+hw==
MIME-Version 1.0
X-Received by 10.107.130.98 with SMTP id e95mr4119107iod.87.1415127964361; Tue, 04 Nov 2014 11:06:04 -0800 (PST)
In-Reply-To <CAF0TK52vw_SmqexN8RXyGs8GSKecPobK54ZqYPyKgRSSJy9zWw@mail.gmail.com>
References <CAF0TK51TKs+tw=u_rzrWVeSsDK7cOBt1Gcvq_izLfMObuDYNig@mail.gmail.com> <545919B6.7040007@stoneleaf.us> <CAF0TK52vw_SmqexN8RXyGs8GSKecPobK54ZqYPyKgRSSJy9zWw@mail.gmail.com>
Date Tue, 4 Nov 2014 13:06:04 -0600
Subject Re: [Python-Dev] Dinamically set __call__ method
From Skip Montanaro <skip.montanaro@gmail.com>
To Roberto Martínez <robertomartinezp@gmail.com>
Content-Type multipart/alternative; boundary=001a113ec986a0c3fb05070d27c5
Cc Python <python-list@python.org>, Nathaniel Smith <njs@pobox.com>
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.15464.1415127972.18130.python-list@python.org> (permalink)
Lines 42
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1415127972 news.xs4all.nl 2894 [2001:888:2000:d::a6]:57020
X-Complaints-To abuse@xs4all.nl
X-Received-Bytes 5040
X-Received-Body-CRC 911799969
Xref csiph.com comp.lang.python:80219

Show key headers only | View raw


[Multipart message — attachments visible in raw view] - view raw

On Tue, Nov 4, 2014 at 1:01 PM, Roberto Martínez <robertomartinezp@gmail.com
> wrote:

> The workaround of calling a different method inside __call__ is not valid
> for my case because I want to change the *signature* of the function also
> -for introspection reasons.


You could define __call__ like so:

def __call__(self, *args, **kwds):
    self._my_call(*args, **kwds)

then set self._my_call at runtime.

Skip

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


Thread

Re: [Python-Dev] Dinamically set __call__ method Skip Montanaro <skip.montanaro@gmail.com> - 2014-11-04 13:06 -0600

csiph-web