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


Groups > comp.lang.python > #80224

Re: [Python-Dev] Dinamically set __call__ method

References <CAF0TK51TKs+tw=u_rzrWVeSsDK7cOBt1Gcvq_izLfMObuDYNig@mail.gmail.com> <545919B6.7040007@stoneleaf.us> <CAF0TK52vw_SmqexN8RXyGs8GSKecPobK54ZqYPyKgRSSJy9zWw@mail.gmail.com> <CANc-5Uy6umBttv7PeztRYGSHhWvyVWDMsKCPnF51RSPG1Uurug@mail.gmail.com> <CAF0TK50_q2auuamT7merw6POXudRA4g_OMkyohhKbPNrsfjLGg@mail.gmail.com>
Date 2014-11-04 19:23 +0000
Subject Re: [Python-Dev] Dinamically set __call__ method
From Nathaniel Smith <njs@pobox.com>
Newsgroups comp.lang.python
Message-ID <mailman.15469.1415128992.18130.python-list@python.org> (permalink)

Show all headers | View raw


On Tue, Nov 4, 2014 at 7:15 PM, Roberto Martínez
<robertomartinezp@gmail.com> wrote:
>
>
> 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. :(

I'd suggest starting a new thread on python-list (or stack overflow or
whatever) explaining what the heck you're trying to do here and asking
for higher-level advice/suggestions, because your current
implementation strategy seems to have placed you on a path that is
rapidly descending past "spaghetti" towards "tentacular".

(Or alternatively I guess you could go all in: Iä! Iä! Metaclasses Fhtagn!)

-n

-- 
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
http://vorpus.org

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


Thread

Re: [Python-Dev] Dinamically set __call__ method Nathaniel Smith <njs@pobox.com> - 2014-11-04 19:23 +0000

csiph-web