This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author shura_zam
Recipients shura_zam
Date 2009-04-15.03:41:00
SpamBayes Score 0.00016764709
Marked as misclassified No
Message-id <1239766862.72.0.608424365256.issue5759@psf.upfronthosting.co.za>
In-reply-to
Content
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]
History
Date User Action Args
2009-04-15 03:41:03shura_zamsetrecipients: + shura_zam
2009-04-15 03:41:02shura_zamsetmessageid: <1239766862.72.0.608424365256.issue5759@psf.upfronthosting.co.za>
2009-04-15 03:41:01shura_zamlinkissue5759 messages
2009-04-15 03:41:00shura_zamcreate