[Python-Dev] Semantics of __int__(), __index__()
francis
francismb at email.de
Sun Mar 31 21:13:59 CEST 2013
> and two instances
> i1 = Int1()
> i2 = Int2()
>
> we get the following behaviour:
>
> >>> type(int(i1))
> <class 'int'>
>
> I would have expected 'Int1'
>>> type(float(i1))
<type 'float'>
>>> type(float(i2))
<class 'float'>
>>> isinstance(int(i1), int)
True
>>> isinstance(int(i2), int)
new <class '__main__.Int2'>
True
>>> isinstance(float(i1), float)
True
>>> isinstance(float(i2), float)
True
why is printing new <class '__main__.Int2'>?
More information about the Python-Dev
mailing list