In Python, None
is in fact a falsy value (i.e. it evaluates to False
in a boolean context).
For example, when you explicitly cast None
to a boolean, it would return False
:
print(bool(None)) # False
Similarly, when you use None
in a boolean context, it's evaluated to False
:
if None: # do something # equivalent to if bool(None): # do something
if not None: # do something # equivalent to if not bool(None): # do something
Hope you found this post useful. It was published . Please show your love and support by sharing this post.