On Tue, Aug 28, 2012 at 9:08 AM, Peter Otten <[email protected]> wrote:
>
> That would reject "floats with an integral value" and therefore doesn't
> comply with the -- non-existing -- spec.
Gotcha.
>> >>> import numbers
>> >>> isinstance("42", numbers.Integral)
>> False
>> >>> numbers.Integral.register(str)
>> >>> isinstance("42", numbers.Integral)
>> True
>
> That's quite an elaborate scheme to shoot yourself in the foot ;)
It was just a quick example. In practice what could happen is someone
would register an integer-like class (instead of subclassing
numbers.Integral or numbers.Number) that is incomplete and ends up
raising an exception.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor