Let us consider the following class definition:
class Main:
x = 1
def __init__(self):
self.y = 5
In this case, we can refer x directly like: Main.x i.e. it is a class attribute, this belongs to every objects of this class.
>>>Main.x
1
But, attribute y is specific to each object. We can not refer it directly like this:
>>> Main.y
Traceback (most recent call last):
File "", line 1, in
AttributeError: class Main has no attribute 'y'
You need to instantiate an object of the class Main to refer to y:
>>> obj = Main()
>>> obj.y
5
This is similar to static variables in C++ and Java.