-
Notifications
You must be signed in to change notification settings - Fork 11
Best Practices
raphaelreinauer edited this page May 15, 2022
·
5 revisions
`from typing import Any
class C: def f(self): print("Hello from C")
class D: def init(self, c: C): self.c = c def g(self): print("Hello from D")
# Forward the call of the function f to the object c
def __getattr__(self, name: str) -> Any:
if name == "g":
return self.name
return getattr(self.c, name)
c = C() d = D(c) d.f() d.g()