P
Philipp Hagemeister
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEAREKAAYFAkqdPDoACgkQ9eq1gvr7CFyIzQCeKE+C1Wm+KJMAlnZVyjvvJcM9
jnoAoLqGSyxc98uP3UERrBmQ3G1NUQAw
=3oBI
-----END PGP SIGNATURE-----
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
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)
iEYEAREKAAYFAkqdPDoACgkQ9eq1gvr7CFyIzQCeKE+C1Wm+KJMAlnZVyjvvJcM9
jnoAoLqGSyxc98uP3UERrBmQ3G1NUQAw
=3oBI
-----END PGP SIGNATURE-----