[Python-ideas] Should bool continue to inherit from int?

Greg Ewing greg.ewing at canterbury.ac.nz
Wed Jan 21 22:09:44 CET 2015


Chris Angelico wrote:

> All of them allow you to write stuff like:
> 
> if (((1==1) + (1==0) + (0==0)) == 2)

Packing a number of booleans into an int is another
case where bool-int equivalence comes in handy. I've
found myself annoyed by this in Java on more than one
occasion recently. (Java neither allows bools to be
used as ints nor non-bools to be used directly as
truth values.)

-- 
Greg


More information about the Python-ideas mailing list