Why should you create a new instance of a class?

Good Day Dear Community,

Just wondering why every time we need to create a new instance of the class?

Why can’t we use the class itself?

Thanks a lot!

1 Like

Hello, @AntonSurov.

According to the Python documentation, creating a new class creates a new type of object, allowing new instances of that type to be made. So the class is basically the definition of an object and its methods, but not the object itself. When you create a new instance you tell Python that that object belong to that class.

For example, when you run df = pd.DataFrame() you are instantiating the object of a class as you are telling python that df belongs to the DataFrame class and now you can use all the methods of this class on df.


Hi @otavios.s,

Thank a lot for your reply! Now I can see better the difference between class and an object.


1 Like

Thank you for asking this question. I had the same thought and a search for answer brought me here.