[Python-Dev] index (was str with base)

Jim Jewett jimjjewett at gmail.com
Tue Jan 17 15:49:46 CET 2006


Guido wrote:

> more important to implement __index__() in Python 2.5.
> This behaves like __int__() for integral types, but is not
> defined for float or Decimal.

Why not for Decimal, or even float?  I would not be surprised
if 10.798 failed, but I would expect 1000D to work.

If indexing worked with more arbitrary extension integers,
then I would expect it work with Decimal, and possibly float,
when the number == a whole number, and to raise ValueError
otherwise.

-jJ


More information about the Python-Dev mailing list