Message85979
Test case:
[code]
class S:
def __init__(self, v):
self.data = v
def __int__(self):
print("S.INT called")
return int(str(self.data))
def __float__(self):
print("S.FLOAT called")
return float(str(self.data))
class T(str):
def __int__(self):
print("T.INT called")
return int(str(self))
def __float__(self):
print("T.FLOAT called")
return float(str(self))
class U(unicode):
def __int__(self):
print("U.INT called")
return int(unicode(self))
def __float__(self):
print("U.FLOAT called")
return float(unicode(self))
i = S("123")
print(type(int(i)))
print(type(float(i)))
i = T("123")
print(type(int(i)))
print(type(float(i))) # <<< CALLS __float__ NOTHING
i = U("123")
print(type(int(i)))
print(type(float(i)))
[/code]
Output:
[code]
S.INT called
<type 'int'>
S.FLOAT called
<type 'float'>
T.INT called
<type 'int'>
<type 'float'>
U.INT called
<type 'int'>
U.FLOAT called
<type 'float'>
[/code] |
|
Date |
User |
Action |
Args |
2009-04-15 03:41:03 | shura_zam | set | recipients:
+ shura_zam |
2009-04-15 03:41:02 | shura_zam | set | messageid: <1239766862.72.0.608424365256.issue5759@psf.upfronthosting.co.za> |
2009-04-15 03:41:01 | shura_zam | link | issue5759 messages |
2009-04-15 03:41:00 | shura_zam | create | |
|