Path: csiph.com!usenet.pasdenom.info!gegeweb.org!de-l.enfer-du-nord.net!feeder2.enfer-du-nord.net!cs.uu.nl!news.stack.nl!newsfeed.xs4all.nl!newsfeed6.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.002 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'cpython': 0.05; '"""': 0.07; 'callable': 0.09; 'foo': 0.09; 'none)': 0.09; 'def': 0.13; '**kwargs)': 0.16; '**kwargs):': 0.16; '*args,': 0.16; 'foo(object):': 0.16; 'jython': 0.16; 'to:addr:pearwood.info': 0.16; 'to:addr:steve+comp.lang.python': 0.16; "to:name:steven d'aprano": 0.16; 'traceback.': 0.16; 'cc:addr:python-list': 0.16; 'received:74.125.82.44': 0.16; 'received:mail-ww0-f44.google.com': 0.16; '(most': 0.21; 'cc:no real name:2**0': 0.21; 'trying': 0.21; 'header:In-Reply-To:1': 0.22; 'traceback': 0.24; 'do,': 0.25; 'cc:2**0': 0.26; 'skip:_ 20': 0.26; 'message-id:@mail.gmail.com': 0.29; 'true,': 0.29; 'class': 0.29; "skip:' 10": 0.29; 'cc:addr:python.org': 0.29; 'typeerror:': 0.30; 'subject:?': 0.31; 'actually': 0.31; 'instead': 0.33; 'object': 0.33; 'file': 0.34; '17,': 0.34; 'last):': 0.34; 'subject:How': 0.35; 'received:74.125.82': 0.36; 'passed': 0.37; 'received:google.com': 0.37; 'skip:_ 10': 0.38; 'received:74.125': 0.38; 'might': 0.40; 'more': 0.61; 'full': 0.62; 'subject:. ': 0.63; 'here': 0.64; 'show': 0.66; 'bar,': 0.93 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=HtaGVyIffo7mWwt1BsCn2dy/3kQtObyrSkA8Rfh4+gk=; b=M/C+e2xod38pjQeP4BWRC6yz59cwMu/HqcJbkke9VRtzgOdf7/5XzwnP9j9oHIbr1I GdFrWnfD7xFd8bsuzAs0Zc9iOBJE2FSr0u1m5PrNlo5GJIaSY6HckgpikxMst8ShS7B9 tDcTRjsBtEeVzHnR5KLm8hoZBQKaePn6pO7DrnolYp6SvRQyuQ8hHuNQYqqWJGmM7TWC VfyvMa92TDk9RslCsJKYgmeo8ld71hfyqvKJk4NBgVhxNfe1fX00MxO77HiE5htks5Pi i2ayYKS30oh+BDkNpUr/WpS2Ypn8f6drakJ4AHe2ihWLRPVZGBYpSOl1zBwMouC2CUVY 8YpQ== MIME-Version: 1.0 In-Reply-To: <4f53433c$0$29989$c3e8da3$5496439d@news.astraweb.com> References: <4f53433c$0$29989$c3e8da3$5496439d@news.astraweb.com> Date: Sun, 4 Mar 2012 21:14:46 +0700 Subject: Re: Jython callable. How? From: Sirotin Roman To: "Steven D'Aprano" Content-Type: text/plain; charset=UTF-8 Cc: python-list@python.org X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 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: 45 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1330870489 news.xs4all.nl 6958 [2001:888:2000:d::a6]:35668 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:21199 > Perhaps if you show us what you actually do, and what happens, we might > be able to tell you what is happening. Please COPY AND PASTE the full > traceback. Here is my code: # Trying to make callable staticmethod class sm(staticmethod): def __call__(self, *args, **kwargs): """ I know here is one more potential problem, because object passed instead of real class """ return self.__get__(None, object)(*args, **kwargs) issubclass(sm, Callable) class Foo(object): @sm def bar(): print("ololo") print("inside", bar, callable(bar), bar()) if __name__=="__main__": print("class outise", Foo.bar, callable(Foo.bar), Foo.bar()) f = Foo() print("instance outside", f.bar, callable(f.bar), f.bar()) cpython output: ololo ('inside', <__main__.sm object at 0xb72b404c>, True, None) ololo ('class outise', , True, None) ololo ('instance outside', , True, None) jython output: Traceback (most recent call last): File "sm.py", line 17, in class Foo(object): File "sm.py", line 23, in Foo print("inside", bar, callable(bar), bar()) TypeError: 'staticmethod' object is not callable