NoneAdvanced Examples

Represents the absence of a value; Python's null equivalent

NoneType singleton behavior

Understanding that None is a singleton.

python
# None is a singleton
a = None
b = None
print(f"a is b: {a is b}")
print(f"id(a) == id(b): {id(a) == id(b)}")

# NoneType can't be instantiated
print(f"type(None): {type(None)}")

# None in containers
values = [1, None, "hello", None, 3]
non_none = [v for v in values if v is not None]
print(f"Filtered: {non_none}")

# None is falsy but not equal to other falsy values
print(f"None == False: {None == False}")
print(f"None == 0: {None == 0}")
print(f"None == '': {None == ''}")

None is a singleton — there is only ever one None object in memory. It is falsy but not equal to other falsy values like 0, False, or ''.

Want to try these examples interactively?

Open Advanced Playground