observer pattern tasks [task(user )task(user )task(user )for task in taskstask complete(print(userif __name__ ="__main__"main(now you have list of objects to be called back when the task is completedand the task need not know anything more about the objects in the callbacks list other than that they have complete_task(method that takes the task that just completed as parameter whenever you want to dynamically decouple the source of call from the called codethis is the way to go this problem is another one of those very common problemsso common that this is another design pattern--the observer pattern if you take step back from the problem we are looking at and just think of the observer pattern in general termsit will look something like this there are two types of objects in the patternan observable classwhich can be watched by other classesand an observer classwhich will be alerted whenever an observable object the two classes are connected to undergoes change in the original gang of four bookthe observer design pattern is defined as followsa software design pattern in which an objectcalled the subjectmaintains list of its dependentscalled observersand notifies them automatically of any state changesusually by calling one of their methods it is mainly used to implement distributed event handling systems [gammae helmr johnsonr vlissidesj design patternselements of reusable object-oriented software publisheraddison-wesley in codeit looks like thisimport abc class observer(object)__metaclass__ abc abcmeta @abc abstractmethod def update(selfobserved)pass