Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!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; 'classes,': 0.05; 'subject:Python': 0.06; 'class,': 0.07; 'from:addr:ethan': 0.09; 'from:addr:stoneleaf.us': 0.09; 'from:name:ethan furman': 0.09; 'message-id:@stoneleaf.us': 0.09; 'subject:method': 0.09; 'subject:set': 0.09; '~ethan~': 0.09; 'factory,': 0.16; 'subject:Dev': 0.16; 'wrote:': 0.18; 'subject:] ': 0.20; 'creating': 0.23; 'header:User-Agent:1': 0.23; 'instance,': 0.24; 'options': 0.25; 'header:In-Reply-To:1': 0.27; 'function': 0.29; 'correct': 0.29; 'am,': 0.29; '(unless': 0.31; 'workaround': 0.31; 'class': 0.32; 'probably': 0.32; 'option': 0.32; 'actual': 0.34; 'could': 0.34; 'really': 0.36; 'instances': 0.36; "didn't": 0.36; 'method': 0.36; 'two': 0.37; 'to:addr :python-list': 0.38; 'realize': 0.39; 'to:addr:python.org': 0.39; 'either': 0.39; 'received:173': 0.61; 'first': 0.61; 'different': 0.65; 'positively': 0.84; 'absolutely': 0.87 Date: Tue, 04 Nov 2014 11:12:15 -0800 From: Ethan Furman User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: Python Subject: Re: [Python-Dev] Dinamically set __call__ method References: <545919B6.7040007@stoneleaf.us> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit 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: 16 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1415128339 news.xs4all.nl 2856 [2001:888:2000:d::a6]:36055 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:80222 On 11/04/2014 11:01 AM, Roberto Martínez wrote: > Yikes, I didn't realize the difference in inheritance. > > The thing with this is tricky. I need the change in the instance, not in the class, because I have multiple instances > and all of them must have different implementations of __call__. > > 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. 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. The first option may work if you don't need an actual class, both of the last two options will be creating different classes, probably with one instance each (unless you have several instances which could share the same __call__). -- ~Ethan~