call a static property on an instance of a class in python

To call a static property on an instance of a class in Python, you can use the syntax instance_name.static_property_name. Here is an example:

main.py
class MyClass:
    static_property = 123

my_instance = MyClass()
print(my_instance.static_property)  # Output: 123
116 chars
6 lines

In the example above, static_property is a static property of the MyClass class. We can access it using the syntax Class_name.property_name as well as instance_name.property_name. This is because static properties are associated with the class and not with any particular instance of the class. Therefore, there is no real difference between calling a static property on the class itself or on an instance of the class.

gistlibby LogSnag