python class
class method, variable / instance method, variable
Demonstrate in below code:
class Student:
# class var
title = 'student'
# constuctor
def __init__(self, name):
# setup instance var
self.name = name
# def class method
@classmethod
def info(cls):
print(cls.title)
# def instance method
def show(self):
cls = self.__class__
print(cls.title, self.name)
student = Student("Leecy")
student.show()
Student.info()