TypeError: unsupported operand type(s) for -: 'Decimal' and 'Decimal'. Why?
Zentrader
zentraders at gmail.com
Tue Jul 31 01:31:04 CEST 2007
> from decimal import Decimal
>
> In [21]: a = Decimal()
>
> In [22]: class Decimal(object):
> ....: pass
> ....:
>
> In [23]: b = Decimal()
>
> In [24]: a - b
Perhaps I don't understand what you are doing here, but on line 22 you
overload Decimal. If you just have
a = Decimal()
b = Decimal()
print a-b yields 0. decimal.Decimal() can be subtracted from
decimal.Decimal(). decimal.Decimal() can not be subtracted from class
Decimal(object). I would assume that they are different types. Using
the original code, print type(a), type(b).
More information about the Python-list
mailing list