Class1 inside Class: Error: Page1.__init__.My_Data.__init__() got an unexpected keyword argument 'Name'


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'

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


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

        def function1(self):

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

            for row in x.fetchall():
                if row[0] not in My_Dictionary:
                    Data = My_Data(

>Solution :

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

Leave a Reply Cancel reply