Mixing Decimal and float
B.V.
bv.tryton at gmail.com
Wed Jun 2 04:24:13 EDT 2010
Hi,
In order to solve some issues due to operations between Decimal and
float, we wanted to implement a class that inherits from both float
and Decimal.
Typically, we wrote:
class Float(Decimal, float):
...
This can not be achieved because of a TypeError exception (with
message "multiple bases have instance lay-out conflict").
With a class that inherits from Decimal, with overridden __add__,
__mul__, .... , we succeed to solve operations issues.
But we also need to do:
isinstance(Float('1'), float) == True
isinstance(Float('1'), Decimal) == True
which is, AFAIK, only possible with Float(Decimal, float).
Is there a workaround ?
We are developping with python version 2.5 and 2.6.
Thanks for your help.
B.
More information about the Python-list
mailing list