6π
β
In the general case of checking if something is None
.. just check it?
if x is not None and x.is_valid():
...
In Python, or
and and
both short circuit, meaning that in the expression x and y
, y
is not evaluated if x
is false
(since the expression is false no matter what y
is).
π€Brendan Long
Source:stackexchange.com