[Python-Dev] Decimal & returning NotImplemented (or not)

Raymond Hettinger python at rcn.com
Tue Mar 1 14:22:51 CET 2005


> A recent question on c.l.p pointed out that the 2.4 Decimal
implementation
> raises TypeError directly for operator arguments it doesn't
understand,
> instead
> of returning NotImplemented.
> 
> Obviously, this creates problems for anyone trying to define a class
that
> 'plays
> nicely' with Decimal (but does not inherit from Decimal), since their
> __rop__
> methods never get called - Decimal's TypeError gets in the way.

Try to address this in a larger context than decimal.  The same sort of
logic is present in sets.py and in datetime objects.



Raymond



More information about the Python-Dev mailing list