In the context of Boolean operations, and also when expressions are used by flow control operators, the following values ββare interpreted as false: False, None, numeric zero of all types and empty strings and containers (including strings, tuples, lists, dictionaries, sets, and freezensets). All other values ββare interpreted as true.
The expression x and y first evaluates x; if x is false, its value is returned; otherwise, y is computed and the return value is returned.
An expression x or y first evaluates x; if x is true, its value is returned; otherwise, y is computed and the return value is returned.
Read more about logical operations for more information: http://docs.python.org/reference/expressions.html#boolean-operations
source share