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
| Name | Type | Description |
|---|---|---|
| obj | object | Object to inspect or copy. |
Return Value
bool
The bool result described above.
Working Example
Example Snippetpython
import operatorprint(operator.truth([0]))