logo       

Special method names problem?: msg#00006

lang.jython.user

Subject: Special method names problem?

Hi,

What I have in jython is:

>>> class C:
... v=0
... def __init__(self,val):
... self.v=val
... def __int__(self):
... return int(self.v)
... def __chr__(self):
... return chr(self.v)
>>> c=C(33)
>>> print int(c)
33
>>> print chr(c)
Traceback (innermost last):
File "<console>", line 1, in ?
TypeError: chr(): 1st arg can't be coerced to int
>>> for i in range(c):
... print i
...
Traceback (innermost last):
File "<console>", line 1, in ?
TypeError: range(): 1st arg can't be coerced to int

In CPython these statements don't present any problem.

I am quite new to Python and jython.

Eugene.

PS I have looked at the language reference and __chr__ doesnt appear to be in it however removing it from the class definition doesn't alter the results in any way.



-------------------------------------------------------
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>
Google Custom Search

News | FAQ | advertise