What is Null in Python?

In Python, there is no such thing as Null. Instead, there is a singletona class that can have only one instance called None that can be easily used in if conditions, functions, and classes.

None is not equivalent to 0, False, Null, or an empty variable. It is its own type.

To check that a variable is None, we use the is operator:

myvar = None
print(myvar is None) #True
z = None
print(z) #None

We can also use it as the result of a function:

def get_none():
pass
myret = get_none()
print(myret is None) #True

Free Resources