Truthiness

Denis McMahon denismfmcmahon at gmail.com
Thu Oct 23 18:07:14 CEST 2014


On Thu, 23 Oct 2014 16:47:27 +0200, Alain Ketterlin wrote:

> says: "In the context of Boolean operations, and also when expressions
> are used by control flow statements, 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 frozensets). All other values are interpreted as true."

Yep, and I expect this to bite S4H shortly, when he can't understand why 
the following are not all of the same truthiness:

0 (falsey - numeric 0)
[] (falsey - empty set)
"" (falsey - empty string)
[""] (truthy - non empty set)
[0] (truthy - non empty set)

-- 
Denis McMahon, denismfmcmahon at gmail.com



More information about the Python-list mailing list