Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

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'

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")

            for row in x.fetchall():
                if row[0] not in My_Dictionary:
                    Data = My_Data(
                        Name=row[1],
                        Year=row[2])

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>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
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading