What's NoneType in Python?

In Python, "NoneType" is the data type for the built-in constant "None" (which implies absence of value). None is the only instance of the NoneType type:

print(type(None)) # <class 'NoneType'>

The NoneType is not available in some versions of Python (as noted below):

  • Python 2.7: NoneType is defined as a type in the types module;
  • Python 3.0 - 3.9: NoneType is removed from the types module (however, it's accessible via type(None));
  • Python 3.10: NoneType is added back to the types module.

This post was published by Daniyal Hamid. Daniyal currently works as the Head of Engineering in Germany and has 20+ years of experience in software engineering, design and marketing. Please show your love and support by sharing this post.