|
Special method names problem?: msg#00006lang.jython.user
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> |
|---|---|---|
| Previous by Date: | Re: Question regarding passing external commandline arguements, Dave Kuhlman |
|---|---|
| Next by Date: | Re: Special method names problem?, Jeff Emanuel |
| Previous by Thread: | Question regarding passing external commandline arguements, Srikrishna_Parthasarathy |
| Next by Thread: | Re: Special method names problem?, Jeff Emanuel |
| Indexes: | [Date] [Thread] [Top] [All Lists] |
| News | FAQ | advertise |