Python Hack - Dynamically override an object
While working with Locust 1 recently, we ran into a situation where we had to dynamically override an attribute in a class in the Locust library so as to control what value it got assigned. After a lot of scratching our heads and reading the Python documentation, we came across the property function. We were able to use this to hack together a solution that ensures that every time an attribute is read, it returns the result of executing a method.
blog.sdqali.in