Python object() Function

Beginner
5 min read
Updated: Nov 2026
3 examples
Built-in type

Definition

In Python, object is the base class of every class: ints, strings, lists, and your own classes all inherit from it, directly or indirectly. Calling object() creates a new, completely featureless instance.

A bare object() has no __dict__, so you cannot attach attributes to it. What it does have are the default methods every object inherits, such as __eq__, __hash__, __repr__, and __str__. Because each object() is unique, it is a popular sentinel value for “no argument given”.

object is a built-in type (a class) that you call like a function: each call creates a new object object. Like every built-in, it lives in the builtins module and is always available without an import.

Syntax

It takes no arguments.

python
marker = object()
CallWhat it does
object()A new, unique, empty object.
isinstance(x, object)Always True.
object() == object()False: equality defaults to identity.
class A: ...Implicitly class A(object).

Printing a bare object shows its type and a memory address, which changes on every run; compare it with is instead of printing it.

Library declarations
python
object()
# class object: the root of the class hierarchy

Parameters

object() takes no arguments; passing any raises TypeError.

Return Value

Return ValueDescription
objectA new featureless instance.

Python Examples

Example 1 — Every Class Inherits from object

Check that built-in types and your own classes all have object as their base.

python
class Point:
    pass


print(issubclass(Point, object))
print(isinstance(42, object), isinstance("hi", object))
print(Point.__mro__[-1] is object)
print(type(object()).__name__)

How It Works

  1. Implicit base. class Point: is the same as class Point(object):.
  2. Everything is an object. Even 42 and "hi" are instances of object.
  3. End of the MRO. object is always the last class in the method resolution order.
  4. Type name, not the object. Printing type(...).__name__ avoids the address in the default repr.

Example 2 — A Bare object() Has No __dict__

Try to add an attribute to object(), then compare with an empty class.

python
plain = object()

try:
    plain.name = "Ana"
except AttributeError:
    print("object() instances cannot get new attributes")

print(hasattr(plain, "__dict__"))


class Empty:
    pass


e = Empty()
e.name = "Ana"
print(e.__dict__)

How It Works

  1. No storage. object() has no per-instance dictionary, so assignment raises AttributeError.
  2. Check with hasattr. hasattr() confirms that __dict__ is missing.
  3. Subclasses get a dict. Instances of a normal class, even an empty one, store attributes in __dict__.
  4. Lightweight by design. Not having a dict keeps bare objects small, which suits sentinel markers.

Example 3 — Use object() as a "No Value" Marker

Tell “no default given” apart from None, and list some default methods.

python
_MISSING = object()


def lookup(data, key, default=_MISSING):
    if key in data:
        return data[key]
    if default is _MISSING:
        raise KeyError(key)
    return default


print(lookup({"a": None}, "a"))
print(lookup({}, "b", 0))
print(object() == object(), _MISSING == _MISSING)
names = ("__eq__", "__hash__", "__repr__", "__str__")
print(sorted(n for n in dir(object) if n in names))

How It Works

  1. A unique default. Nobody else can pass _MISSING, so default is _MISSING reliably means “not given”.
  2. None is a real value. The key "a" exists with value None, and it is returned correctly.
  3. Identity equality. Two different object() instances are never equal; an object equals itself.
  4. Inherited defaults. dir(object) includes the methods every class starts with.

Frequently Asked Questions

The base class of all classes. Every value is an instance of object, and every class inherits its default methods.
A bare object() has no __dict__. Use a small class, types.SimpleNamespace, or a dict instead.
No. All classes inherit from object automatically; class A: is enough.
Mostly as a unique sentinel value, for example a default that means "no argument passed", distinct from None.
The default repr includes a memory address that changes between runs. Compare objects with is rather than printing them.

Next: oct()

Octal string of an integer, prefixed with 0o.

oct() →

About the author

Mari Selvan M P
Mari Selvan M P 🔗

Developer, cloud engineer, and technical writer

  • Experience 12 years building web and cloud systems
  • Focus Full Stack Development, AWS, and Developer Education

I write practical tutorials so students and working developers can learn by doing—from databases and APIs to deployment on AWS.

10 people found this page helpful