0

I have two classes and i'm trying to create third class that inherits two previous. The problem is that i need to pull argument of first class that creates inside first class initialisation into the second is intpossible ?

class FirstClass:
    def __init__(self, token, **kwargs):
        self.token = token
        self.filename = # do some stuff with token and renturns filename

        super().__init__(**kwargs)

# second class contains methods for managing files so i have to pass the filename
class SecondClass:
    def __init__(self, folder, filename, **kwargs):
        self.folder = folder
        # ...
        # do some stiff with forlder and filename
        # ...
    
        super().__init__(**Kwargs)

class ThirdClass(FirstClass, SecondClass):
    def __init__(self, token, folder):
        super().__init__(
        token=token,
        folder=folder,
        #filename=FirstClass.filename ???
    )

TypeError: __init__() missing 1 required positional argument: 'filename',

The "filename" argument creates in init() of FirstClass, but I need it to initialise ThirdClass is it possible to do something like this:

class ThirdClass(FirstClass, SecondClass):
    def __init__(self, token, folder):
        # somehow initialise FirstClass
        # and then call super() with self.filename argument

It is important for me that the third class inherits the methods of the previous two

Kriptos
  • 11
  • 1

0 Answers0