How to trigger function on value change?
I realise this question has to do with event-handling and i've read about Python event-handler a dispatchers, so either it did not answer my question or i completely missed out the information. I want method m() of object A to be triggered whenever value v is changing: For instance (assuming money makes happy): global_wealth = 0 class Person() def __init__(self): self.wealth = 0 global global_wealth # here is where attribute should be # bound to changes in 'global_wealth' self.happiness = bind_to(global_wealth, how_happy) def how_happy(self, global_wealth): return self.wealth / global_wealth