publish-subscribe pattern the first step might seem trivialbut you will soon realize how simple it is to change the way you think about things by just changing what you call them class subscriber(object)def update(selfobserved)print("observing{}format(observed)class publisher(object)def __init__(self)self callbacks set(self changed false def register(selfcallback)self callbacks add(callbackdef unregister(selfcallback)self callbacks discard(callbackdef unregister_all(self)self callbacks set(def poll_for_change(self)if self changedself update_all def update_all(self)for callback in self callbackscallback(selflike saidthis makes no difference in what the program can actually dobut what it does do is help us see things differently we could now take another step forward and rename the methods in both these classes to reflect the publisher-subscriber model more closely