EC Lecture Notes - Lecture 8: Init, Mecha, Class Variable
Document Summary
An instance or non-static variables are different for different objects (every object has a copy). The class may have a static variable whose value is cse for all objects. And class may also have non-static members like name and roll. In c++ and java, we can use static keywords to make a variable a class variable. The variables which don"t have a preceding static keyword are instance variables. See this for java example and this for c++ example. The python approach is simple; it doesn"t require a static keyword. All variables which are assigned a value in the class declaration are class variables. And variables that are assigned values inside methods are instance variables. # python program to show that the variables with a value. # assigned in class declaration, are class variables. # class for computer science student class csstudent: stream = "cse" def __init__(self,name,roll): # class variable self. name = name self. roll = roll.