Everything is an object

An object is a fundamental building block of an object-oriented language. Integers, strings, floating point numbers, even arrays and dictionaries, are all objects. More specifically, any single integer or any single string is an object. The number 12 is an object, the string "hello, world" is an object, a list is an object that can hold other objects, and so on. You've been using objects all along and may not even realize it.

Objects have types

Every object has a type, and that type defines what you can do with the object. For example, the int type defines what happens when you add something to an int, what happens when you try to convert it to a string, and so on.

Conceptually, if not literally, another word for type is class. When you define a class, you are in essence defining your own type. Just like 12 is an instance of an integer, and "hello world" is an instance of a string, you can create your own custom type and then create instances of that type. Each instance is an object.

Classes are just custom types

Most programs that go beyond just printing a string on the display need to manage something more than just numbers and strings. For example, you might be writing a program that manipulates pictures, like photoshop. Or, perhaps you're creating a competitor to iTunes and need to manipulate songs and collections of songs. Or maybe you are writing a program to manage recipes.

A single picture, a single song, or a single recipe are each an object of a particular type. The only difference is, instead of your object being a type provided by the language (eg: integers, strings, etc), it is something you define yourself.

Answer from Bryan Oakley on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-object
Python object - GeeksforGeeks
July 12, 2025 - Python is object-oriented, meaning it focuses on objects and their interactions. For a better understanding of the concept of objects in Python. Let's consider an example, many of you have played CLASH OF CLANS, So let's assume base layout as the class which contains all the buildings, defenses, resources, etc.
🌐
TutorialsPoint
tutorialspoint.com › what-is-an-object-in-python-explain-with-examples
What is an object in Python? Explain with examples
Object basically related everything ... belonging to same class can have different properties. For example, Person(Human) can be treated as a class which has properties such as name, age,gender etc....
Discussions

What exactly is an object in Python?
An object is a data structure that can have properties and methods. A property is a piece of data like a string, integer, or another object. Think of it as a variable within the variable. A method is a function built into the object which it can be called to carry out. Like any other function it takes arguments but it also has access to any of the object's properties. In Python an object is defined by a class, which says what properties objects of that type will have and what methods they can execute. This is how most object oriented languages do it, with the exception of Javascript, which uses an entirely different framework. From a class one can create multiple instances of an object. Each instance will have the same properties, but set to different values. Each instance will be able to do the same methods. For example imagine a Student object. It would have a name, age, grade, and so on. It could have the moveUp() method, which would increase the Student's grade. A file object is just a kind of object Python can create that allows it to do things to a file, like read from it or write to it. A number is technically an object in Python. This is not the case in all object oriented languages. But it's better thought of as a "primitive," meaning the stuff that other objects can be made of. A number only has one piece of data, the number itself, and doesn't have any built in methods (I think). This barely scratches the surface of object oriented programming. Google "python oop" and read various resources and you'll learn a lot more. More on reddit.com
🌐 r/learnprogramming
2
2
April 29, 2022
What is meant by "everything in python is an object"
Every function is an object, as well: >>> def func(): ... return True >>> func.__name__ 'func' I access the class attribute __name__ on the newly created function, to demonstrate it has attributes just like an object. More on reddit.com
🌐 r/learnpython
16
10
January 10, 2019
Can Someone Explain Objected Oriented Programming In Python Like I'm an Idiot?

There's a massive Wikipedia page on OOP that will give you every little gritty detail. And, there are a lot of OOP evangelists and an ever increasing amount of OOP cynics. Either of which will try to sell you benefits of Language-X, and why Language-Z is the greatest invention since the wheel. Including these 30,000 words of rhetoric, fallacies, and pure garbage.

Here is everything you need to know about OOP. There are three features that make a language an OO language. Any language can have one or two of the features and not be OO, but any language that has all three can be considered OO. They are:

  1. Encapsulation

  2. Inheritance

  3. Polymorphism

Encapsulation is a feature that allows for a data structure to be associated with a set of methods*; An object. In a language without encapsulation, like C, then you will have libraries of functions* and each piece of data is passed to a function. In a language with OO, like Python, you can define a Class that, when instantiated, creates an object. That object, usually, is an aggregate datatype with added logic, methods*. Each instance method has an implicit argument, typically, named self.

* A note on the terms "method" and "function". They're both just synonymous with "subroutine" or a sequence of instructions. However, most programmers differentiate them. A "subroutine" is blockless piece of code that must be reached by a goto statement. A "function" is a block of code that operates exclusively on it's arguments. And, a "method" is a block of code that is associated with an object.

Most languages have generic base "types" like strings, integers, floats, and arrays. When have a need for a "type" with several associated values, then you need an 'aggregated data type'. In a language without Encapsulation, the term is usually called a "struct". With Encapsulation, a "type" is nearly synonymous with a "class" and an instance is called an "object". There's, also, a spectrum of OO-ness. Java base types are NOT objects. An int in Java is not an object, it is a type, but an Integer is an object. In Python everything is an object.

A crude example in Python would be:

class Greeter(object):
    def __init__(self, phrase):
        self.phrase = phrase

    def greet(self, name):
        print(self.phrase.format(name))

hello_greeter = Greeter("Hello, {}!")
hello_greeter.greet("Ms. Smith")

In the above example, we see our first hint of Inheritance. The Greeter class inherits from object (Note: (object) is implicit in Python3.) Inheritance is the ability to associate and expand on another class's data structure and functionality. We could very easily create a HelloWorldGreeter from Greeter.

class HelloWorldGreeter(Greeter):
    def __init__(self):
        super(HelloWorldGreeter, self).__init__("Hello, {}!")

    def greet(self):
        super(HelloWorldGreeter, self).greet("World")

In the Inheritance realm there is single-inheritance and multiple-inheritance. The HelloWorldGreeter is an example of a class with single-inheritance. In fact, must OO languages are specifically only single-inheritance. However, I mention it here because Python isn't most languages as it allows for multiple-inheritance. Which is the reason for the very explicit super(...) function. This function is able to solve the "diamond problem" which is an issue about how inheritance is ordered. I'll just stop here because it's a lengthy topic in itself; follow the link to Wikipedia for more. If you want to know more Python's super(...) method, then read Raymond Hettinger's post "Python's super() considered super!"

A lot of detractors consider inheritance -- especially, multiple inheritance -- as a complicated obfuscation that makes code harder to debug.

That leaves us with Polymorphism. This will be the most difficult for me to explain and, I suspect, the most contentious of OO features. And, it's going to require us to take a step back.

All languages have a "type system". There are a few adjectives that get thrown around. The two that most people confuse (and I might do so myself) are the mutually exclusive "weakly" (or "loosely") typed and "strongly" typed languages. Also, there are other concepts that are frequently confused as 'strong' and 'weak' which are "static type-checking" and "dynamic type-checking". To unravel all of this, here is the best I can do to concisely describe these concepts:

  • Strongly Typed: A strongly typed language is one that will cause an error if a piece of logic tries to operate on an unexpected type. Something that tends to confuse a lot of people is the fact that Python (and Ruby) are strongly typed. I'll try to explain later in 'Dynamic Type-Checking'.

  • Weakly Typed: A language that attempts to perform type conversion would be considered "weakly" typed. Java, for instance, does "auto-boxing" and "auto-unboxing" for it's basic types; ex int fortytwo = 20 + new Integer(22). In C, one can add pointers to numeric types and numeric types can be coerced into another numeric types; ex. an int can safely converted to long.

  • Static Type-Checking: A static type-checking language is one that tracks each object's type to prevent type-specifc logic errors. For example, one shouldn't pass a string to a function that expects to receive two integers. Typically, this is a compile time feature which gives an added performance benefit because the resulting program does not need runtime type checking.

However, languages like javascript and Python (PEP 484) are adding "type hinting" which can be thought of as "unenforced static type-checking". Rather than halting compilation, errors and warnings will be presented.

  • Dynamic Type-Checking: A dynamic type-checking language is one that does not make any attempt to protect the program for logic errors based on object type. That is to say, type checking must be done at runtime through language-specific functionality. For example, if one wanted to run a specific function on an object, then one might want to be certain that the object provides that functionality or, else, risk a runtime error. This is commonly known as "duck typing"; Coming from the common phrase, 'If it walks like a duck and quacks like a duck, then it is a duck'.

Okay. Back to Polymorphism. A language is considered polymorphic if an object can be treated as its own specific type or any of the inherited types, or "subtypes". A quick example just to wrap this up (because I've written way to much):

class Vehicle(object):
    pass

class Truck(Vehicle):
    pass

class Car(Vehicle):
    pass

isinstance(Car(), Car) # True
isinstance(Truck(), Car) # False

isinstance(Car(), Vehicle) # True
isinstance(Truck(), Vehicle) # True

Hope it helps.

More on reddit.com
🌐 r/learnpython
45
157
November 18, 2016
Explain it to me like I'm Five: Classes + __init__ function

Classes are data encapsulated with structure and behaviour. You use them when you have similar things that all behave the same way or all share meaning.

If you had a Dog class, well, all Dogs have a name, breed, colour, and all Dogs have the same behavior, barking, wagging, running.

The __init__ method is the constructor. This method is called when the object is created. You use it to set up the initial state of the object. When a Dog is created it 'gets' a name, breed and colour.

For a real programming example, say you are making a shooter game. In this game you can equip many different weapons which have different characteristics but all function more or less the same way. You could make a Weapon class which has data like ammunition capacity, bullets remaining, or damage done. Then you could make this class have a shoot() method and when the user presses a button when playing the game it calls this method. Inside the method it checks to see if there is ammunition remaining in the magazine, and if so, removes a bullet from the magazine. And if the user needs to reload you can make a reload() method which checks how much ammunition the player has, and if there is enough left, refills the magazine and removes the bullets from the ammunition pile.

Then you can take this class and make many child classes all with different properties and maybe with additional behaviour, but still basicaly function the same as every other weapon.

More on reddit.com
🌐 r/learnpython
41
57
January 8, 2014
Top answer
1 of 8
20

Everything is an object

An object is a fundamental building block of an object-oriented language. Integers, strings, floating point numbers, even arrays and dictionaries, are all objects. More specifically, any single integer or any single string is an object. The number 12 is an object, the string "hello, world" is an object, a list is an object that can hold other objects, and so on. You've been using objects all along and may not even realize it.

Objects have types

Every object has a type, and that type defines what you can do with the object. For example, the int type defines what happens when you add something to an int, what happens when you try to convert it to a string, and so on.

Conceptually, if not literally, another word for type is class. When you define a class, you are in essence defining your own type. Just like 12 is an instance of an integer, and "hello world" is an instance of a string, you can create your own custom type and then create instances of that type. Each instance is an object.

Classes are just custom types

Most programs that go beyond just printing a string on the display need to manage something more than just numbers and strings. For example, you might be writing a program that manipulates pictures, like photoshop. Or, perhaps you're creating a competitor to iTunes and need to manipulate songs and collections of songs. Or maybe you are writing a program to manage recipes.

A single picture, a single song, or a single recipe are each an object of a particular type. The only difference is, instead of your object being a type provided by the language (eg: integers, strings, etc), it is something you define yourself.

2 of 8
10

To go deep, you need to understand the Python data model.

But if you want a glossy stackoverflow cheat sheet, let's start with a dictionary. (In order to avoid circular definitions, let's just agree that at a minimum, a dictionary is a mapping of keys to values. In this case, we can even say the keys are definitely strings.)

def some_method():
    return 'hello world'

some_dictionary = {
    "a_data_key": "a value",
    "a_method_key": some_method,
}

An object, then, is such a mapping, with some additional syntactic sugar that allows you to access the "keys" using dot notation.

Now, there's a lot more to it than that. (In fact, if you want to understand this beyond python, I recommend The Art of the Metaobject Protocol.) You have to follow up with "but what is an instance?" and "how can you do things like iterate on entries in a dictionary like that?" and "what's a type system"? Some of this is addressed in Skam's fine answer.

We can talk about the python dunder methods, and how they are basically a protocol to implementing native behaviors like sized (things with length), comparable types (x < y), iterable types, etc.

But since the question is basically PhD-level broad, I think I'll leave my answer terribly reductive and see if you want to constrain the question.

🌐
Berkeley
pythonnumericalmethods.studentorg.berkeley.edu › notebooks › chapter07.02-Class-and-Object.html
Class and Object — Python Numerical Methods
For example, student1.name is “Susan” and student2.name is “Mike”. But when we print out the class attribute Student.n_instances after we created object student2, the one in the student1 changes as well. This is the expectation we have for the class attribute because it is shared across all the created objects. Now that we understand the difference between class and instance, we are in good shape to use basic OOP in Python.
🌐
Datamentor
datamentor.io › python › classes-object
Python Classes and Objects (With Examples)
There are also special attributes in it that begin with double underscores __. For example, __doc__ gives us the docstring of that class. As soon as we define a class, a new class object is created with the same name.
🌐
Reddit
reddit.com › r/learnprogramming › what exactly is an object in python?
r/learnprogramming on Reddit: What exactly is an object in Python?
April 29, 2022 -

Thinkpython book by Allen Downey defines objects as something a variable can refer to to which he adds "object" and "value" can be used interchangeably. So, if my understanding serves me well, a variable stores a value, for e.g. x = 5, does that imply 5 is an object as well?

Then, I come across "file object" which is known to bear reference to a file. Maybe I'm overcomplicating things that's why I can't seem to grasp these concepts.

Top answer
1 of 2
2
An object is a data structure that can have properties and methods. A property is a piece of data like a string, integer, or another object. Think of it as a variable within the variable. A method is a function built into the object which it can be called to carry out. Like any other function it takes arguments but it also has access to any of the object's properties. In Python an object is defined by a class, which says what properties objects of that type will have and what methods they can execute. This is how most object oriented languages do it, with the exception of Javascript, which uses an entirely different framework. From a class one can create multiple instances of an object. Each instance will have the same properties, but set to different values. Each instance will be able to do the same methods. For example imagine a Student object. It would have a name, age, grade, and so on. It could have the moveUp() method, which would increase the Student's grade. A file object is just a kind of object Python can create that allows it to do things to a file, like read from it or write to it. A number is technically an object in Python. This is not the case in all object oriented languages. But it's better thought of as a "primitive," meaning the stuff that other objects can be made of. A number only has one piece of data, the number itself, and doesn't have any built in methods (I think). This barely scratches the surface of object oriented programming. Google "python oop" and read various resources and you'll learn a lot more.
2 of 2
1
Say, you have a store called Doggo World and they offer specials for whoever signs their dog up. In the form, you have to put in some information. Dog's name Dog's breed Dog's age Dog is chipped (true/false) Master's name Master's phone number These 5 pieces of information are called different things in different languages such as fields, member variables, instance variables. This information that should be printed out in a form can be called a class which is like a recipe. A recipe is not a dish until you cook it. A class is not an object until you create it. Another analogy is a book has a bunch of words. Those words for a book form a "class", and the actual book is an object. You can have many books but they are considered the same. You don't need a class but many OO languages use them as the basis to create objects. An object generally has several features. First, the fields (we'll call them fields) are usually inaccessible for direct access. This is known as encapsulation. This is mostly to prevent direct access to the data. The reason for this is typically data validation. If the field contained a test score, you might want to ensure the values are between 0 and 100. However values generally have a type (like int) and that has a much larger range than 0 and 100. In this case, maybe you want to make sure that the phone number has a valid format. Instead, access is done though methods called getters/setters and possibly other methods that do other things. So far, that makes what you've done "object based". I won't go through more details to discuss inheritance but some argue that this is a necessary feature of OO programming. In Java, it's not used much because of interfaces which I also won't go through much. As far as whether 5 is an object, it depends on the language. Usually an object has methods on it. In Java, there is a primitive type called int where 5 is not an object, and one where it is Integer which is an object. It might start off as not an object, but Java does something called autoboxing which converts and int to an Integer or an Integer to an int. In some languages, everything is an object, so 5 can be an object. I think in Python it probably is an object as Python numbers can grow in size past the largest value an int can have. For files, typically, the File object references a location of a file, but you still need to do operations like opening a file, closing a file, reading and writing from a file. So it doesn't really represent the file's content, but you can use it to access the contents through methods. It represents some information about where this file should be located (there may not be a file there, but that's OK).
🌐
Javatpoint
javatpoint.com › what-is-an-object-in-python
What is an object in Python - Javatpoint
Patch.object python · Pause in python script · Best Python Interpreters to Use in 2023 · NumPy Attributes · Expense Tracker Application using Tkinter in Python · Variable Scope in Python · Alphabet in Python · Python Find in List · Python Infinity · Flask Authentication in Python · Fourier Transform Python · IDLE Software in Python · NumPy Functions · APSchedular Python Example ·
Find elsewhere
🌐
Programiz
programiz.com › python-programming › class
Python Classes and Objects (With Examples)
In the above example, we have created two objects employee1 and employee2 of the Employee class. We can also define a function inside a Python class.
🌐
W3Schools
w3schools.com › python › python_classes.asp
Python Classes/Objects
Almost everything in Python is an object, with its properties and methods.
🌐
Alma Better
almabetter.com › bytes › tutorials › python › objects-in-python
What is Object in Python?
June 26, 2024 - It defines what information an object can contain and what methods it can execute 💻. An example of an object in Python is the list 📝. A list is a container that holds items 📁. Each item can be accessed using its index 🔢. We can add ...
🌐
Scaler
scaler.com › home › topics › python › what is object in python?
What is Object in Python? - Scaler Topics
June 16, 2023 - We have the concept of classes and objects in Python to keep related things together as it is an "object-oriented-language". Let's take the example of a bookshelf. Here we sort the books into different shelves according to their genre.
🌐
Real Python
realpython.com › python3-object-oriented-programming
Object-Oriented Programming (OOP) in Python – Real Python
December 15, 2024 - Object-oriented programming is ... objects. For example, an object could represent a person with properties like a name, age, and address and behaviors such as walking, talking, breathing, and running....
🌐
ScholarHat
scholarhat.com › home
Classes and Objects in Python (Explained with Examples)
September 10, 2025 - We can create multiple objects in a Python class easily. Below is an example you can try in Python Editor:
🌐
Medium
medium.com › @bdov_ › https-medium-com-bdov-python-this-is-an-object-that-is-an-object-everything-is-an-object-fff50429cd4b
Python Objects Part I: This is an Object, That is an Object — Everything is an Object! | by Brennan D Baraban | Medium
January 21, 2019 - All objects in Python are represented by a generalized structure used to describe and access a particular value’s information and methods. One such piece of information is an object’s type. To determine the type of an object, you can use the built-in method of the same name, type(). Building on the above example, the type of x, which refers to the value 1, is the numeric type int:
🌐
HackerEarth
hackerearth.com › practice › python › object oriented programming › classes and objects i
Classes and Objects I Tutorials & Notes | Python | HackerEarth
>>> class Snake: ... name = "python" # set an attribute `name` of the class ... You can assign the class to a variable. This is called object instantiation. You will then be able to access the attributes that are present inside the class using the dot . operator. For example, in the Snake example, you can access the attribute name of the class Snake.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-classes-and-objects
Python Classes and Objects - GeeksforGeeks
dog1.name accesses the object’s instance attribute and dog1.species accesses the shared class attribute. __str__ method allows us to define a custom string representation of an object. By default, when we print an object or convert it to a string using str(), Python uses the default implementation, which returns a string like <__main__.ClassName object at 0x00000123>. Take an example of using __str__() method to provide a readable string output for an object:
Published   1 week ago
🌐
Python documentation
docs.python.org › 3 › tutorial › classes.html
9. Classes — Python 3.14.3 documentation
In a sense the set of attributes of an object also form a namespace. The important thing to know about namespaces is that there is absolutely no relation between names in different namespaces; for instance, two different modules may both define a function maximize without confusion — users of the modules must prefix it with the module name. By the way, I use the word attribute for any name following a dot — for example, in the expression z.real, real is an attribute of the object z.
🌐
WsCube Tech
wscubetech.com › resources › python › classes-and-objects
Classes and Objects in Python: How to Create, With Examples
October 1, 2025 - Learn about Python classes and objects, how to create them, with examples in this step-by-step tutorial for mastering object-oriented programming.
🌐
Tutorialspoint
tutorialspoint.com › python › python_classes_objects.htm
Python - Classes and Objects
The entities used within a Python program is an object of one or another class. For instance, numbers, strings, lists, dictionaries, and other similar entities of a program are objects of the corresponding built-in class.
🌐
Intellipaat
intellipaat.com › home › blog › python classes and objects
Python Classes and Objects (With Examples)
October 14, 2025 - Q2. How do you create an object in Python? You can create an object by calling the name of the class like a function, for example: obj = ClassName() creates an instance of ClassName.