Skip to content

Static variable in Python | Basics

  • by

Python Static variables are declared a variable inside a class, but outside the function (method). Static variables are also known as class variables in Python.

Examples Static variable in Python

A simple example code shows that the variables with a value assigned in a class declaration, are static variables.

class MyClass:
    i = "Static Variable"



Static variable in Python

Do comment if you have any doubts and suggestions on this Python variable topic.

Note: IDE: PyCharm 2021.3.3 (Community Edition)

Windows 10

Python 3.10.1

All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.

Leave a Reply

Your email address will not be published. Required fields are marked *