Object
A single value built from a class, with its own attributes and methods. Also called an instance.
An object (or instance) is created by calling a class like a function: Dog("Rex"). Each object carries its own attributes, so two objects of the same class can hold different values.
In Python everything is an object — numbers, strings, lists, even functions and classes themselves. You work with an object through its attributes and methods, reached with a dot.
class Point:
def __init__(self, x, y):
self.x = x
self.y = y
a = Point(1, 2) # one object
b = Point(5, 9) # another, with its own values
print(a.x, b.x)
print(isinstance(a, Point))
Output
1 5 True
Where this shows up in real Python
Everything in Python is an object — numbers, strings, functions, and every instance of your own classes.
Commonly used Object tools
type(obj)— what class made this objectisinstance(obj, Cls)— is it that type (or a subclass)dir(obj)— list its attributes and methodsvars(obj)— its instance data as a dict
Official documentation: Python Language Reference: Objects, values and types