I have a scenario where class A is initialized with parameters id,name,email,ticket. Then class B is initialized inside class A's method and the same parameters are required to be passed along and so on and so forth. Can these common attributes be set using a decorator or metaclass during class declaration.
class A:
def __init__(self, id, name, email, ticket):
self.id = id
self.name=name
self.email=email
self.ticket=ticket
def __somefunc(self):
# do something
b = B(self.id, self.name, self.email, self.ticket)
b.__dosomething()
Similarly...class C and so on.. I am finding it bit inappropriate sending all these repeated parameters to all the subsequent classes.
A.__init__andB.__init__? A class methodB.from_Amight also be appropriate, to encapsulate the process of creating an instance ofBgiven an instance ofA.Can these common attributes be set using ...? set on the instance created in__somefunconly or onAalso?