This function takes any value and converts it to a Boolean (true
or false) value.
x
For the list of values that are considered True
or False, see Section 7.3, “Type bool: Boolean truth values”.
Examples:
>>> bool(0)
False
>>> bool(0.0)
False
>>> bool(0L)
False
>>> bool(0j)
False
>>> bool('')
False
>>> bool([])
False
>>> bool(())
False
>>> bool({})
False
>>> bool(None)
False
>>> bool(1)
True
>>> bool(15.9)
True
>>> bool([0])
True
>>> bool((None,))
True
>>> bool({None: False})
True