mercredi 22 mai 2019

How to pass function arguments between classes

I have a ClassA that I use in different situations.

ClassA:
    def __init__(self, Avalue1, Avalue2, args*):
    ...
    def myAFunction(self):
    for a in self.args:
        ...

Now I have a Class B that uses myAFunction to accomplish something but during the initialisation I have also to determine what values are passed thru to Class A.

ClassB:
    def __init__(self, Bvalue1, Bvalue2, Avalue1, Avalue2, args*)
    ...
    def myBFunction(self):
        class_A = ClassA
        class_A.myAFunction(Avalue1, Avalue2, args*)

Is there any kind of design pattern to solve this problem? This must be something many people are facing.

Aucun commentaire:

Enregistrer un commentaire