Equivalent code to the bool() built-in function

Gregory Ewing greg.ewing at canterbury.ac.nz
Sun Apr 17 20:12:29 EDT 2011


Chris Angelico wrote:

> Well, of course you can always implement bool as an int;

Which Python used to do once upon a time -- and still does
in a way, because bool is a subclass of int.

The bool type was added mainly to provide a type that prints
out as 'True' or 'False' rather than 1 or 0. This can be
a considerable help for debugging and keeping the conceptual
meaning of one's data clear.

-- 
Greg



More information about the Python-list mailing list