A possible change to decimal.Decimal?
ethan at stoneleaf.us
Sun Mar 4 16:38:58 CET 2012
A. Lloyd Flanagan wrote:
> On Friday, March 2, 2012 6:49:39 PM UTC-5, Ethan Furman wrote:
>> Jeff Beardsley wrote:
>> What you should be doing is:
>> import decimal
>> from decimal import Decimal
>> Decimal = decimal.Decimal # (rebind 'Decimal' to the reloaded code)
> Agree that's how the import should be done. On the other hand, removing gratuitous use of isinstance() is generally a Good Thing.
Gratuitous use? How is it gratuitous for an class to check that one of
its arguments is its own type?
def __add__(self, other):
if not isinstance(other, Frizzy):
This is exactly what isinstance() is for, and this is how it is being
used in Decimal.__init__().
More information about the Python-list