I have a class with a variety of methods, for example:
class Foo(obj): def meth_a: ... def meth_b: ...
In reality, Foo may have 50 or more methods. And for various reasons, I cannot subclass Foo. I'm using Foo in a composition class with some added functionality. Let's call this class Bar. I want Bar to have a few new methods and attributes, but quack like it was Foo. For example, when the user calls:
My program returns Foo.meth_a().
class Bar(obj): foo=Foo() def meth_a: return self.foo.meth_a()
As such, Bar seems to have all of Foo's methods. Without being able to subclass, is it possible to promote all of these methods without doing it manually? Foo() is extremely complicated and it would be quite laborious to port everything. Can anyone think of a way to do this?
Edited 3 Years Ago by dashing.adamhughes