Python 我的类有一个_uinit _;函数,从未执行的类方法会引发异常

Python 我的类有一个_uinit _;函数,从未执行的类方法会引发异常,python,python-3.x,Python,Python 3.x,使用Python3.9.4 64位 Mac上的VSCode class HomeworkHelper: "This is a HomeworkHelper" def homeworkClassSelection(self, customerClass): if customerClass == "SC": return "SENIOR" if customerCla

使用Python3.9.4 64位 Mac上的VSCode

class HomeworkHelper:
    "This is a HomeworkHelper"
    def homeworkClassSelection(self, customerClass):
        if customerClass == "SC":
            return "SENIOR"
        if customerClass == "TD" or customerClass == "TA":
            return "TEACHER ASSISTANCE"
        if customerClass == "PD" or customerClass == "PA" :
            return "PROFESSOR"
            
    def __init__(self, id=0, firstName="", lastName="", expirationDate="", addressLine1="", addressLine2="", city="", state="", zip="", dateOfBirth="", customerClass=""):
        self.id = id
        self.firstName = firstName
        self.lastName = lastName
        self.expirationDate = expirationDate
        self.addressLine1 = addressLine1
        self.addressLine2 = addressLine2
        self.city = city
        self.state = state
        self.zip = zip
        self.dateOfBirth = dateOfBirth
        self.customerClass = homeworkClassSelection(customerClass) # this line throws exception says that it can't find homeworkClassSelection
使用自我。调用类方法时:

self.homeworkClassSelection(customerClass)
使用self。调用类方法时:

self.homeworkClassSelection(customerClass)

次要挑剔:
homeworkClassSelection
似乎是一种实例方法。尽管如此,您的解决方案仍然适用(例如,如果它是用
@classmethod
@staticmethod
修饰的,则为实例方法)。次要的挑剔:
homeworkClassSelection
似乎是一个实例方法。不过,您的解决方案仍然适用(例如方法,如果它是用
@classmethod
@staticmethod
修饰的)。
NameError: name 'homeworkClassSelection' is not defined