Equivalent code to the bool() built-in function

Gregory Ewing greg.ewing at canterbury.ac.nz
Mon Apr 18 02:08:08 CEST 2011


candide wrote:

> bool(x) is nothing more than a shortcut for the following expression : 
> True if x else False.

It's a much shorter and easier-to-read shortcut.

Also keep in mind that if-else expressions are quite a recent
addition to the language.

Before that, we had 'not not x' as another equivalent

-- 
Greg



More information about the Python-list mailing list