|
Re: Special method names problem?: msg#00007lang.jython.user
__int__ is not used in Jython (2.1) for coersion to ints. Instead, Jython calls the __tojava__ method to convert the object to a java.lang.Integer. This works: >>> import java,org >>> class C: ... v=0 ... def __init__(self,value): ... self.v=value ... def __int__(self): ... return int(self.v) ... def __tojava__(self,t): ... if t is java.lang.Integer: ... return self.__int__() ... return org.python.core.Py.NoConversion ... >>> c=C(33) >>> for i in range(c): ... print i ... 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 Eugene Rosenzweig wrote: Hi, ------------------------------------------------------- This SF.Net email is sponsored by xPML, a groundbreaking scripting language that extends applications into web and mobile media. Attend the live webcast and join the prime developer group breaking into this new coding territory! http://sel.as-us.falkag.net/sel?cmd=lnk&kid=110944&bid=241720&dat=121642
|
|
| <Prev in Thread] | Current Thread | [Next in Thread> |
|---|---|---|
| Previous by Date: | Special method names problem?, Eugene Rosenzweig |
|---|---|
| Next by Date: | RE: Re: Question regarding passing external commandline arguements, Srikrishna_Parthasarathy |
| Previous by Thread: | Special method names problem?, Eugene Rosenzweig |
| Next by Thread: | Dynamic Jython Web programming using MyOODB ( Object-Oriented Database ), Tom Hazel |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |