0

I have a class. Inside this is another class. Inside a function of this class. How can I pass attributes (self) of first class to second class

for example

class FirstClass():
    def __init__(self, e) -> None:
        self.e = e
        # lots of other attributes...

    def e(self):
        pass

    def App(self):
        
        class myapp(overview.App):
            def __init__(self) -> None:
                super().__init__()
                self.geometry("450x650")
                print(self.e))
        
        myapp().mainloop()

print(self.e) one of the attributes of the first class. How do I do this?

It is important for me. Thanks.

  • You will need to change the name of the argument `self` either in `App` or in the inner `__init__`. But that goes against standard Python idiom which raises the question are you really going with the right approach to whatever problem you are trying to solve? Maybe it would be better to take a step back and ask about what you're trying to do instead of about what you think is the solution (see [What is the XY problem?](https://meta.stackexchange.com/q/66377/571958)) – Tomerikoo Dec 11 '22 at 10:36

0 Answers0