Learn Before
Concept

Class Variable vs Instance Variable

Class variables are attributes that are common for all its instances and declared in the class definition. But Instance variables are unique to a particular instance and are declared inside the ___init___() method. For example, if we have a Class called Employee, each employee (an instance) will have unique employee_id, but might have the same manager_id. So in this case, manager_id should be declared as class variable and employee_id should be instance variable.

0

2

Updated 2021-02-08

Contributors are:

Who are from:

Tags

Python Programming Language

Data Science