Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

python3
communitycreator

What is Null in Python?

Dario Vincenzo Tarantini

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

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

RELATED TAGS

python3
communitycreator

CONTRIBUTOR

Dario Vincenzo Tarantini

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring