Skip to content

Object

In one line

An object is a specific instance of a class, containing its own data (attributes) and behavior (methods).

In simple words

An object is a concrete instance created from a class. While the class is the blueprint, the object is the actual thing built from it, with its own specific data.

In Python, everything is an object — integers, strings, lists, functions, and even classes themselves are objects. You can check an object's type with type() and its available attributes and methods with dir().

Each object has its own identity (memory address, checkable with is), type, and value. Two objects can have the same value but different identities. Objects are created by calling the class like a function: obj = MyClass(args).

Example

python
class Point:
    def __init__(self, x, y):
        self.x = x
        self.y = y

p1 = Point(3, 4)
p2 = Point(3, 4)

print(p1.x, p1.y)    # 3 4
print(p1 is p2)      # False (different objects)
print(type(p1))      # <class '__main__.Point'>

# Everything is an object
print(type(42))      # <class 'int'>
print(type("hi"))    # <class 'str'>

Objects are instances of classes with their own data. In Python, everything is an object.

Common confusions

  • Confused with: class

    The difference: A class is the definition/blueprint. An object is a specific instance created from the class. One class can produce many objects, each with different attribute values.

Related terms

Related Resources

Related Lessons

Decode error messages

Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.

View errors

← Back to glossary