I would like to create a class that inherites from None
.
Tried this:
class InvalidKeyNone(None):
pass
but that giv
None
is a constant, the sole value of types.NoneType
(for v2.7, for v3.x)
Anyway, when you try to inherit from types.NoneType
from types import NoneType
class InvalidKeyNone(NoneType):
pass
foo = InvalidKeyNone()
print(type(foo))
you'll get this error
Python 2
TypeError: Error when calling the metaclass bases type 'NoneType' is not an acceptable base type
Python 3
ImportError: cannot import name 'NoneType'
in short, you cannot inherit from NoneType
Anyway, why would want a class to inherit NoneType
?