I have a project, with some modules each of which contains a class doing their respective thing. Then I have an API class for the user. The API class instantiate those classes, and should forward/redirect to those who are doing the actual processing. I have the following questions:
How do I do the forwarding without rewriting what seems to me redundant code? For example, say
Foois the API class,Baris a module class, then now I am writing something like:class Foo: def __init__(self, bar: Bar): self.bar = bar def name(self): return self.bar.name()I explicitly wrote
namemethod inFoo, which just returnsname()ofBar. Isn't this redundant? Is there an "automatic" way to forward the call?In the
barclass I'd write some docstrings. Is there a way to "port" these docstrings to the API classFoo? Writing them again inFoowould be redundant and difficult to maintain.