Equivalent code to the bool() built-in function

Gregory Ewing greg.ewing at canterbury.ac.nz
Mon Apr 18 20:18:34 EDT 2011


John Nagle wrote:
>    Pascal got this right.  (A nice feature of Pascal
> was that "packed array of boolean" was a bit array).
> C, which originally lacked a "bool" type, got it wrong.
> So did Python.

If Python had had a boolean type from the beginning, it
probably wouldn't have been a subclass of int -- that was
more or less forced by backwards compatibility issues.

> Java is in the middle, with an isolated
> "boolean" type but a system that allows casts.

I'm not sure that's all that much different from Pascal,
where you can use ord() to turn a boolean into an int
if you want to. At least you're being explicit.

-- 
Greg



More information about the Python-list mailing list