python static class variable code example
Example 1: static class python
>>>class Calculator:
@staticmethod
def multiplyNums(x, y):
return x * y
>>>print('Product:', Calculator.multiplyNums(15, 110))
Product:1650
Example 2: python class static variable
>>> class MyClass:
... i = 3
...
>>> MyClass.i
3
Example 3: creating a static property in python
class Example:
staticVariable = 5
print(Example.staticVariable)
instance = Example()
print(instance.staticVariable)
instance.staticVaraible = 6
print(instance.staticVariabel)
print(Example.staticVariable)
Example.staticVariable = 7
print(Example.staticVariable)