DEV Community

Discussion on: Distinguishing Instance Variables from Class Variables in python

Collapse
 
cvasudev profile image
cvasudev

So in this case you have used class variable to store a constant however is there any other use case where we can use class variable instead of instance variable?

Collapse
 
ogwurujohnson profile image
Johnson Ogwuru • Edited

So whenever you need to create a variable that needs to be shared by all instances or methods in a class, then and only then it makes sense to use class variables