Truthiness

Steven D'Aprano steve+comp.lang.python at pearwood.info
Thu Oct 23 20:42:47 EDT 2014


Ian Kelly wrote:

> No, 3 is merely true, not True.  True is just the name of a particular
> singleton object that is also true.

Sometimes I distinguish between "true" and "True", where True is the
canonical boolean true object, but I prefer to refer
to "true-like", "true-ish", or "truthy" objects as a shorthand
for "evaluates the same as True in a boolean context"

Likewise for "false-like, false-ish, falsey" for objects which evaluate the
same as False in a boolean context.

It should also be pointed out that, for built-ins and the standard library
at least, a good distinction to make is that representations of Nothing
(e.g. None, empty string, empty list, zero, empty set, etc.) are falsey,
while representations of Something (e.g. non-empty strings, non-empty
lists, numbers other than zero, non-empty sets, etc.) are truthy.


-- 
Steven




More information about the Python-list mailing list