Jython callable. How?

Sirotin Roman web.elektro.net at gmail.com
Sun Mar 4 15:14:46 CET 2012

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

   def bar():

   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:
('inside', <__main__.sm object at 0xb72b404c>, True, None)
('class outise', <function bar at 0xb72a680c>, True, None)
('instance outside', <function bar at 0xb72a680c>, True, None)

jython output:
Traceback (most recent call last):
 File "sm.py", line 17, in <module>
   class Foo(object):
 File "sm.py", line 23, in Foo
   print("inside", bar, callable(bar), bar())
TypeError: 'staticmethod' object is not callable

More information about the Python-list mailing list