Just had a major mental block on the word delegation. While in software design and implementation the three (along with association) are very similar they aren’t precisely the same. More importantly searching on aggregation and composition wasn’t getting me the info I needed for what I was trying to do in Python, so I ended up writing a 25 line function where a 1 line function would have done. The one line implementation is simply:
def __getattr__(self, attrib):
return getattr(self.delegate, attrib)
and if I had been more knowledgeable of all of Python’s magic methods I wouldn’t not have needed to search at all. That said the longer function I wrote, although not needed at present, isn’t necessarily wasted as it allows for easy delegation to more then one delegate instance. This also tells me that I need to spend more time on my “Concise Effective Python” document as one of the things Effective C++ did was call out and discuss the intricacies of C++’s magic methods of which there are quite a few less then there are for Python.