Operator Functions

operator.truth()

Return the Boolean truth value using the same rules as bool(). A nonempty container is true even if its elements are false.

Formal Syntax & Structure

python syntaxpython
operator.truth(obj, /)

Parameters & Attributes

NameTypeDescription
objobjectObject to inspect or copy.

Return Value

bool

The bool result described above.

Working Example

Example Snippetpython
import operatorprint(operator.truth([0]))
Python Reference