Answers for "why static kwyword not in python"

0

why static kwyword not in python

Variables declared inside the class definition, but not inside a method are class or static variables:

>>> class MyClass:
...     i = 3
...
>>> MyClass.i
3 
As @millerdev points out, this creates a class-level i variable, but this is distinct from any instance-level i variable, so you could have

>>> m = MyClass()
>>> m.i = 4
>>> MyClass.i, m.i
>>> (3, 4)
Posted by: Guest on February-10-2021

Code answers related to "why static kwyword not in python"

Python Answers by Framework

Browse Popular Code Answers by Language