observer pattern def unregister_all(self)self callbacks set(def update_all(self)for callback in self callbackscallback(selfdef main()observed observable(observer concreteobserver(observed register(lambda xobserver update( )observed update_all(if __name__ ="__main__"main(although there are many ways to string up the actions that can take place once the state of an observable changesthese are two concrete examples to build on sometimesyou might find that you would prefer the rest of the system be updated at specific time and not whenever the object changes to facilitate this requirementwe will add changed flag in protected variable (rememberpython does not explicitly block access to this variableit is more matter of convention)which can be set and unset as needed the timed function will then only process the change and alert the observers of the observable object at the desired time you could use any implementation of the observer pattern combined with the flag in the example that followsi used the functional observer as an exerciseimplement the flag for changed on the example with the object set of observers import time class concreteobserver(object)def update(selfobserved)print("observing{}format(observed)