r/learnpython • u/Forward-Ride2950 • 18d ago
Trying to understand Class, Object, Instance, and self in Python. Is my understanding correct?
I'm currently learning OOP in Python and wrote down some questions regarding object and instance for following code
=
= ```
1) is ?
:- is
2) is ?
:- is and is
3) ?
:- is in is and
pass
50
Upvotes
View all comments
1
u/cdcformatc 18d ago
an object is a generic bundle of state(data/variables) and behavior (methods).
a class is a specification that is used as a blueprint to create instances of objects.
an instance is a specific object, created using the class specification.
self is just a reference to the instance itself. when the program calls a method of a class, that method needs to know what object it is supposed to use.