Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeError: module() takes at most 2 arguments (3 given) code taken from pluralsight course [duplicate]

I am viewing the Pluralsight course on Python. At the end of the module we are to write a Python script. The author does not show how to create two of the scripts. I have them coded as the follows:

main.py

from hs_student import *

james = HighSchoolStudent("james")
print(james.get_name_capitalize)

student.py

students = []


class Student:
    school_name = "Springfield Elementary"

    def __init__(self, name, s_id=332):
        self.name = name
        self.s_id = s_id
        students.append(self)

    def get_name_capitalize(self):
        return self.name.capitalize()
...

hs_student.py

import student as student

students = []


class HighSchoolStudent(student):

    school_name = "Springfield High School"

    def get_school_name(self):
        return "This is a High School student"

    def get_name_capitalize(self):
        original_value = super().get_name_capitalize()
        return original_value + "-HS"

...

When running the code, I get an error. From my understanding, I am passing too many arguments to the get_name_capitalize function. How can I fix this?

The error message is:

TypeError: module() takes at most 2 arguments (3 given)
like image 873
Jinzu Avatar asked Dec 30 '19 21:12

Jinzu


1 Answers

This code:

class HighSchoolStudent(student):

is trying to inherit from the student module, not the student.Student class. Change it to:

class HighSchoolStudent(student.Student):

to inherit from the intended class.

like image 169
ShadowRanger Avatar answered Nov 14 '22 21:11

ShadowRanger