Home > Back-end >  Class inside Class: Error: Page1.__init__.My_Data.__init__() got an unexpected keyword argument 
Class inside Class: Error: Page1.__init__.My_Data.__init__() got an unexpected keyword argument 

Time:01-25

When i try to start my script, i get a error. I have main class Page1 and inside is My_Data class and function1 function. The error is:

TypeError: Page1.__init__.<locals>.My_Data.__init__() got an unexpected keyword argument 'Name'

MyCode.py:

class Page1(tk.Frame):
    def __init__(self, master, other, **kw):
        super().__init__(master, **kw)

        self.configure(bg='white')

        class My_Data():
            def __init__(self):
                self.Name: str
                self.Year: float
                

        def function1(self):

            My_Dictionary = {}
            x = cursor.execute("sql")


CodePudding user response:

It's because My_Data class doesn't have parameters Name and Year in its __init__ function. Just add the two params.

class My_Data():
    def __init__(self, Name, Year):
        self.Name = Name
        self.Year = Year
  • Related