Most Python objects may be converted to Booleans; this is called Boolean casting. The built-in function bool performs that conversion. Note that most objects are cast to True, except 0, the empty tuple, the empty list, the empty string, or the empty array. These are all cast to False.

Table 2.2: Casting rules for Booleans
It is not possible to cast arrays into Booleans unless they contain no or only one element; this is explained further in Section 5.2.1, Boolean arrays. The previous table (see Table 2.2: Casting rules for Booleans) contains summarized rules for Boolean casting.
We demonstrate this by means of some usage examples:
bool([]) # False
bool(0) # False
bool(' ') # True
bool('') # False
bool('hello') # True
bool(1.2) # True
bool(array([1])) # True
bool(array([1,2])) # Exception raised!