1

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)
ShadowRanger
  • 108,619
  • 9
  • 124
  • 184
Jinzu
  • 1,201
  • 1
  • 7
  • 17

1 Answers1

5

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.

ShadowRanger
  • 108,619
  • 9
  • 124
  • 184