class X(object):
    def __int__(self): return 42
    def __hex__(self): return '2b' #sic

hex(X())


What would you expect? Python2 returns '2b', but python 3(74624) throws
TypeError: 'X' object cannot be interpreted as an integer. Why doesn't
python convert the object to int before constructing the hex string?

Regards,

Philipp Hagemeister


Attachment: signature.asc
Description: OpenPGP digital signature

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to