Python TypeError: __init__() got multiple values for argument 'master'

前端 未结 2 646
太阳男子
太阳男子 2021-01-19 16:42

Trying to build a GUI in Python at the moment, and I\'m stuck at this part in particular. Every time I try to run my code it just throws the error TypeError: __init__(

相关标签:
2条回答
  • 2021-01-19 17:26
    super().__init__(self, master = master, **kwargs)
    

    If you're using super(), you don't need to specify self explicitly.

    You are getting that error because self is being interpreted as the argument for master. So it's like if you were calling __init__(master=self, master=master, **kwargs).

    0 讨论(0)
  • 2021-01-19 17:29

    The issue is in the following line in Plotter.__init__() -

    super().__init__(self, master = master, **kwargs)
    

    When calling the parent's __init__ method, you do not need to pass the self argument, when you do that, it is getting treated as the master argument for the parent, and then when you try to pass master as master=master , it causes your error.

    You should simply do -

    super().__init__(master = master, **kwargs)
    
    0 讨论(0)
提交回复
热议问题