I am trying to understand Python 3's syntax for class definitions. I saw that @classmethods seem to be typically used to distinguish a class method and static methods work as methods solely dependent on the parameters passed to it. I don't think I understand the actual application of @classmethod and the implication that "Class method works with the class since its parameter is always the class itself."
Take this example below:
class Student():
# Private attributes of Student Class
__student_id = None
__student_name = None
# Constructor (__init__)
def __init__(self, student_id: int, student_name: str):
self.__student_id = student_id
self.__student_name = student_name
# Public Access Methods
@classmethod
def assign_lab_day(self, day: int) -> None:
self.__lab_day = day
# Print student details
#@classmethod
def display(self) -> None:
print(f'Student ID: {self.__student_id}')
print(f'Student Name: {self.__student_name}')
...
student1 = Student(12345678, 'Jane')
student1.display()
Result
Student ID: None
Student Name: None
Here everything seems to be okay however added the @classmethod to the display function causes the results to be the initialization of None. Given that a display function has the parameter of it's self i.e the host class instance, why would this occur?