observer pattern def unregister(selfobserver)self observers discard(observerdef unregister_all(self)self observers set(def update_all(self)for observer in self observersobserver update(selfin the preceding codethe observable keeps record of all the objects observing it in list called observersand whenever relevant changes happen in the observableit simply runs the update(method for each observer you will notice this every time the update(function is called with the observable object passed as parameter this is the general way of doing itbut any parametersor even no parameterscan be passed to the observersand the code will still adhere to the observer pattern if we were able to send different parameters to different objectsthat would be really interestingsince we would greatly increase the efficiency of the calls if we no longer needed to pass the whole object that has undergone changes let' use python' dynamic nature to make our observer pattern even better for thiswe will return to our user task system general_observer py class concreteobserver(object)def update(selfobserved)print("observing{}format(observed)class observable(object)def __init__(self)self callbacks set(def register(selfcallback)self callbacks add(callbackdef unregister(selfcallback)self callbacks discard(callback