Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin1!goblin.stu.neva.ru!nntp.spacedump.net!usenetcore.com!newsfeed.xs4all.nl!newsfeed2.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.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:: [': 0.04; '-for': 0.05; 'subject:Python': 0.06; '*args,': 0.09; 'arguments': 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>': 0.22; 'cc:addr:python.org': 0.22; 'either.': 0.24; 'skip': 0.24; 'define': 0.26; 'header:In-Reply-To:1': 0.27; 'tried': 0.27; 'function': 0.29; 'ideal': 0.29; 'cc:2**2': 0.30; 'message- id:@mail.gmail.com': 0.30; 'informative': 0.31; 'names.': 0.31; 'workaround': 0.31; 'skip:_ 10': 0.34; 'could': 0.34; 'but': 0.35; 'received:google.com': 0.35; 'method': 0.36; 'implement': 0.38; 'nov': 0.38; 'pm,': 0.38; 'called': 0.40; 'first': 0.61; '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:from:date:message-id:subject:to :cc:content-type; bh=nZKFvX+q17vT1v5uVTvi/dgg8d7OL1lHtK6eMq4LAqg=; b=o79p1QzDyjACwJn1kYz/t0cUSAkB9lhuB19Z5fTb5scwfXquHBN8ue248JZovXa4Xg FqXXw7ujPrBLx/aXhiTjHe/2Cvjk/ZYUn6dT5guyXmprnIZARy3RfGCy3wstffdCNivo tNbbZQkClazIjKmcWstlbI6/1imsKMArilMPLzbUkXwquY1IGJHTg7rhtcy736PBNiWi Y3mEgezhSQRrquFwQEVbsAFFrwb0u4wZYOrvkC+/rv9dsu9Y3r91H/dbjTUD8wPUXfO/ tE60raCscjwepUUQGZIsRgwLf7HARMBQchE1pK94nkBx8ZYQQo0d7j977ZvmYgh6jRiD jrsQ== X-Received: by 10.42.16.74 with SMTP id o10mr3333136ica.61.1415128544190; Tue, 04 Nov 2014 11:15:44 -0800 (PST) MIME-Version: 1.0 In-Reply-To: References: <545919B6.7040007@stoneleaf.us> From: =?ISO-8859-1?Q?Roberto_Mart=EDnez?= Date: Tue, 4 Nov 2014 20:15:24 +0100 Subject: Re: [Python-Dev] Dinamically set __call__ method To: Skip Montanaro Content-Type: multipart/alternative; boundary=20cf303ea7b4304be405070d4a4f Cc: Python , Nathaniel Smith 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: 69 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415128547 news.xs4all.nl 2952 [2001:888:2000:d::a6]:39296 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80223 --20cf303ea7b4304be405070d4a4f Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable On Tue, Nov 4, 2014 at 8:06 PM, Skip Montanaro wrote: > > On Tue, Nov 4, 2014 at 1:01 PM, Roberto Mart=EDnez < > robertomartinezp@gmail.com> wrote: > >> The workaround of calling a different method inside __call__ is not vali= d >> for my case because I want to change the *signature* of the function als= o >> -for introspection reasons. > > > You could define __call__ like so: > > def __call__(self, *args, **kwds): > self._my_call(*args, **kwds) > This was my first approach, but it is not very informative to the user and I prefer to have arguments with descriptive names. We have to change __doc__ too, so this is not an ideal solution for me. I tried to implement __getattribute__, but is not called either. :( then set self._my_call at runtime. > > Skip > > --20cf303ea7b4304be405070d4a4f Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable


On Tue, Nov 4, 2014 at 8:06 PM, Skip Montanaro <skip.montanaro@= gmail.com> wrote:

On Tue, Nov 4, 2014 at 1:01 PM, Roberto Mart=EDnez <robe= rtomartinezp@gmail.com> wrote:
The workaround of calling a different method inside __call__ is not val= id for my case because I want to change the *signature* of the function als= o -for introspection reasons.

You could define= __call__ like so:

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

=
This was my first approach, but it is not very informative to th= e user and I prefer to have arguments with descriptive names. We have to ch= ange __doc__ too, so this is not an ideal solution for me.

I tried to implement __getattribute__, but is not called either. := (

then set self._my_call at runtime.

Skip


--20cf303ea7b4304be405070d4a4f--