How to access the class variables without even creating a instance of class?

Class varaibles are created during class construction hence these variables are accessible even before an instance of class is created.

In below code preview_var variable is accessible even before creating and instance of class.

The class variables (preview_var) can also be accessed with the class instance.

You can also see all the class variables with __dict__ property

A class variable is accessible even before the instance of the class is created. You can use these varaibles to load any metadata information.

But a class varaible is cannot be accessed in class instance __dict__ property. See below code sample for object of class i.e. preview __dict__ property does not show class variable and is empty.

Now if you try to update the class variable with the instance of the class the content of the class variable will be only accesible to that instance and not the other instance.

See below example-

preview instance content is changed and is only accessible to that instance while preview1 instance still has the original content for class_var

While class varaibles as mentioned above holds different content for various instance of same class, they are also called as shared variables only when these class varaibles are changed within the class accessed by the class and not the instance of that class.

Below example shows the instances of the Preview class where the counter incremented when the instance is created but the counter value is shared and can be accessed with the class and instance variable. What is instance variable? see here

see constructor of the class updates the counter accessed by the class. i.e. Preview.counter

I hope this helps to understand class.shared variables and different ways of accessing same.