I don't understand the need for the additional "delegate"-layer in the following code, from Learning Python, 5ed, by Mark Lutz:
class Super:
def method(self):
print('in Super.method')
def delegate(self):
self.action()
class Provider(Super):
def action(self):
print('in Provider.action')
this means that you must specify action-method in your subclass for delegate-method-call to work.
Super().delegate() ====> Error!
Provider().delegate() ====> Works, prints 'in Provider.action'!
why not just code delegate-method in the subclass? In other words, remove delegate from Super altogether and code in Provider only. The result is still Errors from Super.delegate() and results from Provider.delegate().
Could you kindly provide use cases or references/ pointers? Thank you!