Jython callable. How?

Steven D'Aprano steve+comp.lang.python at pearwood.info
Sun Mar 4 11:26:04 CET 2012


On Sun, 04 Mar 2012 16:03:56 +0700, Sirotin Roman wrote:

> Hi.
> How exactly jython decides is object callable or not? I defined __call__
> method but interpreter says it's still not callable. BTW, my code works
> in cpython

Works for me.

steve at runes:~$ jython
*sys-package-mgr*: processing modified jar, '/usr/share/java/servlet-
api-2.5.jar'
Jython 2.5.1+ (Release_2_5_1, Aug 4 2010, 07:18:19)
[OpenJDK Client VM (Sun Microsystems Inc.)] on java1.6.0_18
Type "help", "copyright", "credits" or "license" for more information.
>>>
>>> class Test:
...     def __call__(self):
...             return 42
...
>>>
>>> x = Test()
>>> x()
42


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.



-- 
Steven



More information about the Python-list mailing list