Mixing Decimal and float

Chris Rebert clp2 at rebertia.com
Wed Jun 2 20:00:44 EDT 2010


On Wed, Jun 2, 2010 at 4:11 PM, Steven D'Aprano
<steve-REMOVE-THIS at cybersource.com.au> wrote:
> On Wed, 02 Jun 2010 17:17:11 -0400, Nathan Rice wrote:
>> My apologies if someone already mentioned this and I missed it but...
>>
>> class.__instancecheck__(self, instance) - Return true if instance should
>> be considered a (direct or indirect) instance of class. If defined,
>> called to implement isinstance(instance, class).
>>
>> class.__subclasscheck__(self, subclass) - Return true if subclass should
>> be considered a (direct or indirect) subclass of class. If defined,
>> called to implement issubclass(subclass, class).
>
> The original poster needs to support Python 2.5 and 2.6, but
> __instancecheck__ and __subclasscheck__ are only supported in 2.6 or
> higher, so this doesn't help.

Even in 2.6+, good luck trying to define new methods on class `type`
(the metaclass of float and Decimal).

Cheers,
Chris
--
http://blog.rebertia.com



More information about the Python-list mailing list