Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

python 3 error RuntimeError: super(): no arguments

Why do I get this error? Can someone solve this problem for me? I tried to call the display function from class project in Progress.display() or anybody has other solution on how to display the users input?

And how can I input Stages class and Progress class at the same time ? thanks for the helpp

super().display()
RuntimeError: super(): no arguments

Here's the code

class Project:     def __init__(self, name="", job="", **kwargs):         super().__init__(**kwargs)         self.name = name         self.job = job      def display():         print("name: ", (self.name))         print("job: ", (self.job))      @staticmethod     def prompt_init():         return dict(name=input("name: "), job=input("job: "))   class Stages(Project):     def __init__(self, stages="", **kwargs):         super().__init__(**kwargs)         self.stages = stages      def display(self):         super().display()         print("stages: ", (self.stages))      @staticmethod     def prompt_init():         parent_init = Project.prompt_init()          choice = None         while choice not in (1, 2, 3, 4, 5, 6):              print("Insert your stage now: ")             print("1. Planning")             print("2. Analysis")             print("3. Design")             print("4. Implementation")             print("5. Testing")             print("6. Release")              choice = input("enter your choice: ")             choice = int(choice)              if choice == 1:                 stages = "Planning"             elif choice == 2:                 stages = "Analysis"             elif choice == 3:                 stages = "Design"             elif choice == 4:                 stages = "Implementation"             elif choice == 5:                 stages = "Testing"             elif choice == 6:                 stages = "Release"             else:                 print("no such input, please try again")              print(name)             print(stages)   class Progress(Project):     def __init__(self, progress="", **kwargs):         super().__init__(**kwargs)         self.progress = progress      def display(self):         super().display()         print("progress: ", (self.progress))      @staticmethod     def prompt_init():         parent_init = Project.prompt_init()          choice = None         while choice not in (1, 2, 3, 4):              print("1. 25%")             print("2. 50%")             print("3. 75%")             print("4. 100%")              choice = input("enter your choice[1-4]: ")             choice = int(choice)              if choice == 1:                 progress = "25%"             elif choice == 2:                 progress = "50%"             elif choice == 3:                 progress = "75%"             elif choice == 4:                 progress = "100%"             else:                 print("no such input, please try again")              print(progress)         parent_init.update({"progress": progress})         return parent_init   class A(Stages, Progress):     def prompt_init():         init = Stages.prompt_init()         init.update(Progress.prompt_init())         return init      prompt_init = staticmethod(prompt_init)   class New:     type_map = {("stages", "progress"): A}      def add_project_test(self, name, job, stages):         init_args = Project.prompt_init()         self.project_list.append(Project(**init_args))      def __init__(self):         self.project_list = []      def display_project():         for project in self.project_list:             project.display()             print()      def add_progress(self):         init_args = Progress.prompt_init()         self.project_list.append(Progress(**init_args))      def add_project(self):         ProjectClass = self.type_map[A]         init_args = ProjectClass.prompt_init()         self.property_list.append(ProjectClass(**init_args))   my_list = New() my_list.add_progress() my_list.display_project() 
like image 679
Justin Junias Avatar asked Nov 27 '18 21:11

Justin Junias


1 Answers

Not 100% solution to the answer, but same error. Posted with love for Googlers who have the same issue as me.

Using Python 3, I got this error because I forgot to include self in the method. Simple thing, but sometimes the most simple things trip you up when you're tired.

class foo(object):     def bar(*args):         super().bar(*args) 

=> RuntimeError: super(): no arguments

Remember to include your self

class foo(object):     def bar(self, *args):         super().bar(*args) 
like image 188
John Doe Avatar answered Sep 19 '22 23:09

John Doe