static property class python 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: 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)