To add a public static property to a class in Python, we can use the class decorator @staticmethod along with the built-in @property decorator.
Here is an example:
main.py185 chars8 linesIn the above example, we added a private static variable _my_static_property to the class MyClass. We then defined a static method my_static_property and decorated it with @staticmethod and @property. This allows us to access the private static variable as a public static property.
We can then access the public static property as follows:
main.py58 chars2 lines
gistlibby LogSnag