CKTIS / Python
object()
Creates a fresh instance of the common base class for Python objects.
Version: Python 3.14; repository image, production runtime not attested
Syntax
object()Creates a fresh instance of the common base class for Python objects.
Separate calls create distinct objects. A private sentinel can therefore distinguish a missing value from a stored None.
Each call creates a new featureless instance of the common base class. Keeping one private sentinel lets a dictionary distinguish absent age from city bound to None. The example compares by is, so another object that happens to compare equal cannot impersonate the sentinel. A plain object instance has no instance dictionary.
a, b = object(), object()
assert a is not b and a != b
d = {"city": None}
assert d.get("age", a) is a and d.get("city", a) is None
Examples
missing = object()
record = {"city": None}
print(record.get("city", missing) is missing)
print(record.get("age", missing) is missing)
Result
False True
Each call creates a new featureless instance of the common base class. Keeping one private sentinel lets a dictionary distinguish absent age from city bound to None. The example compares by is, so another object that happens to compare equal cannot impersonate the sentinel. A plain object instance has no instance dictionary.