In Python an integer 0 represents false, and an integer 1 represents true.
Python recognizes any empty data structure as false and any nonempty data structure as true.
The notions of true and false are intrinsic properties of every object in Python.
Each object is either true or false, as follows:
The following table gives examples of true and false values of objects in Python.
Because objects are true or false themselves, it's common to see Python programmers code tests like
which, assuming X is a string, is the same as if X != '':.
You can test the object itself to see if it contains anything, instead of comparing it to an empty.