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

You can call a public static property on an instance of a class in Python using the class name followed by the property name. Here's an example:

main.py
class MyClass:
    foo = 42  # public static property

my_obj = MyClass()
print(MyClass.foo)  # prints 42
print(my_obj.foo)   # also prints 42
143 chars
7 lines

In this example, foo is a public static property of MyClass. To access foo on an instance of MyClass, you can use either the class name (MyClass.foo) or the instance (my_obj.foo). Both ways will give you the same result: 42.

gistlibby LogSnag