[Python-ideas] Boolean ABC similar to what's provided in the 'numbers' module

Steven D'Aprano steve at pearwood.info
Mon Feb 12 08:45:03 EST 2018


On Mon, Feb 12, 2018 at 09:41:04AM +0000, Sylvain MARIE wrote:

> The numbers module provides very useful ABC for the 'numeric tower', 
> able to abstract away the differences between python primitives and 
> for example numpy primitives.
> I could not find any equivalent for Booleans.
> However numpy defines np.bool too, so being able to have an abstract 
> Boolean class for both python bool and numpy bool would be great.

I don't know anything about numpy bools, but Python built-in bools are 
numbers, and as such already have an ABC: they are a subclass of int.



-- 
Steve


More information about the Python-ideas mailing list