Python Forum
[Solved] Please, help me find a simple mistake
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Solved] Please, help me find a simple mistake
#1
Fedora 34, Python 3.9.5

from PyQt5 import QtWidgets
from PyQt5.QtWidgets import QWidget

class M_A(type(QWidget), type):pass
class A(QWidget, metaclass=M_A):
    def __init__(self):
        QWidget.__init__(self)
        
class B:
    def __init__(self, controller):
        self.controller = controller
        
        
class M_C(type(A), type(B)):pass
class C(A, B, metaclass=M_C):
    def __init__(self, controller):
        A.__init__(self)
        B.__init__(self, controller)
        
        
app = QtWidgets.QApplication([])
C(controller=19)
Error:
Traceback (most recent call last): File "/home/ivan/eclipse-workspace/GompertzLaw/Exp.py", line 22, in <module> C(controller=19) File "/home/ivan/eclipse-workspace/GompertzLaw/Exp.py", line 17, in __init__ A.__init__(self) File "/home/ivan/eclipse-workspace/GompertzLaw/Exp.py", line 7, in __init__ QWidget.__init__(self) TypeError: __init__() missing 1 required positional argument: 'controller'
Where is the mistake?
Reply
#2
Is your error that controller is defined as a positional argument, but you are calling it as a keyword argument?
Reply
#3
Decision:

class B:
    def __init__(self, controller=0):
        self.controller = controller
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [SOLVED] [Beautifulsoup] Find if element exists, and edit/append? Winfried 2 4,131 Sep-03-2022, 10:14 PM
Last Post: Winfried
Thumbs Up [SOLVED] Find last occurence of pattern in text file? Winfried 4 4,305 Aug-13-2021, 08:21 PM
Last Post: Winfried
  [split] Could you please clarify where i did mistake also how run without admin right Abubakkar 1 1,753 Jun-14-2021, 09:32 AM
Last Post: Larz60+
  Please help to me to find my mistake in code leonardin 2 1,801 Nov-29-2020, 04:17 PM
Last Post: Larz60+
  minor mistake in code for factorial spalisetty06 2 1,854 Aug-22-2020, 05:00 PM
Last Post: spalisetty06
  Simple mistake about for Nomatter 4 2,183 Jul-16-2020, 02:24 PM
Last Post: Nomatter
  Install Mistake jlerette5 1 1,858 Feb-18-2020, 12:19 AM
Last Post: jefsummers
  What was my mistake in this Python code (easy)? voltman 4 3,382 Nov-19-2019, 09:58 PM
Last Post: snippsat
  countdown script not working..plz help what is mistake randyjack 1 2,079 Oct-28-2019, 06:57 AM
Last Post: perfringo
  Beginner mistake. bbweeg 1 2,003 Aug-17-2019, 07:27 AM
Last Post: perfringo

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020