In Python you have the None
singleton, which acts pretty oddly in certain circumstances:
>>> a = None
>>> type(a)
None
is the just a value of types.NoneType
, it's not a type.
And the error is clear enough:
TypeError: isinstance() arg 2 must be a class, type, or tuple of classes and types
From the docs:
None
is the sole value oftypes.NoneType
.None
is frequently used to represent the absence of a value, as when default arguments are not passed to a function.
You can use types.NoneType
>>> from types import NoneType
>>> isinstance(None, NoneType)
True
is
operator also works fine:
>>> a = None
>>> a is None
True