Skip to content

Instantly share code, notes, and snippets.

@misja
misja / singleton.py
Last active January 3, 2022 00:12
Python None is an object (and a singleton)
# None is of type NoneType
print(f"{None} is of type", type(None))
# Each object contains a reference to its class,
# let's use this to create a new instance of NoneType
NewNone = None.__class__()
# NoneType is a *singleton*, so should be equal
assert NewNone is None