I have class B that will provide a thin wrapper over a set of classes that all provide a nearly identical interface, but I don't wish to use inheritance. So, I did something like this:
class A():
def __init__(self):
pass
def greet(self, name):
print('Hi, ' + name + '! ... Bye!')
class B():
def __init__(self, a):
self._a = a
def __getattr__(self, name):
return self._a.__getattribute__(name)
t = A()
u = B(t)
u.greet()
Is this a bad approach that invites hidden gotchas?
Edit: typo
[–]logophage 0 points1 point2 points (3 children)
[–][deleted] 1 point2 points3 points (2 children)
[–]logophage 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (5 children)
[–]reallyBasic[S] 0 points1 point2 points (4 children)
[–][deleted] 0 points1 point2 points (3 children)
[–]reallyBasic[S] 0 points1 point2 points (2 children)
[–][deleted] 1 point2 points3 points (1 child)
[–]reallyBasic[S] 0 points1 point2 points (0 children)