Python ProgrammingPython Programming

What is class in python?

A class is a blueprint for an object. When we instantiate an object, we use a class as the basis for how the object is built.

Think of a builder who wants to build a building of some type. The builder uses a blueprint to insure that the building will meet the expected specifications. The blueprint itself is not a building, but is a detailed summary of a building. When we use the blueprint to build an actual building, we could say we are building an instance of the building described by the blueprint. Similarly, we can build several identical buildings from the same blueprint. Each building is a separate instance of the building expressed by the blueprint.

Likewise, Python uses classes as a blueprint for creating new objects. Hence, class is a summary of an object's characteristics or components. When the program is functioning, it can use the class to generate, in memory, as many objects of a specific type as required. Each object that is created from a class is called an instance of the class.