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


Groups > comp.lang.python > #80223 > unrolled thread

Re: [Python-Dev] Dinamically set __call__ method

Started byRoberto Martínez <robertomartinezp@gmail.com>
First post2014-11-04 20:15 +0100
Last post2014-11-04 20:15 +0100
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python

This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by below is the oldest one visible, not the original post.


Contents

  Re: [Python-Dev] Dinamically set __call__ method Roberto Martínez <robertomartinezp@gmail.com> - 2014-11-04 20:15 +0100

#80223 — Re: [Python-Dev] Dinamically set __call__ method

FromRoberto Martínez <robertomartinezp@gmail.com>
Date2014-11-04 20:15 +0100
SubjectRe: [Python-Dev] Dinamically set __call__ method
Message-ID<mailman.15468.1415128547.18130.python-list@python.org>

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

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í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)
>

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
>
>

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web