/ Published in: Python
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
# learning python 3rd edition # page 528 class Delegate(object): def __init__(self, wrapper): self.wrapper = wrapper def __getattr__(self, attribute): print "working on" return getattr(self.wrapper, attribute) a_list = Delegate([1,2]) a_list.append(4) working on