You can override a static property on a subclass in python by defining the property in the subclass with the same name as in the parent class. This will override the static property of the parent class for the subclass.
Here is an example:
main.py210 chars9 lines
In this example, we have a Parent
class which defines a static property named my_static_prop
. The Child
class inherits from the Parent
class and overrides the my_static_prop
property with a new value.
When we print the value of my_static_prop
on each class, we can see that the value is different for Parent
and Child
.
By defining a property with the same name in the subclass, Python will look for that property first and use it instead of the property in the parent class.
gistlibby LogSnag