Python `if x is not None` or `if not x is None`?
The proper way to check if a variable x is not None in Python is to use if x is not None.
if x is not None:
# do somethingIt is not recommended to use if not x is None as it is less readable, and the double negation can be confusing.
if not x is None: # not recommended
# do somethingIt is also common and more pythonic to use if x instead of if x is not None
if x:
# do somethingAs None is considered as a False value in python, The above statement will also check if x is not None