class Person(object):
kind = 'human'
def __init__(self):
self.x = 100
#Methods that can be called without creating an object
@classmethod
def what_is_your_kind(cls):
return cls.kind
#Same as a function outside the class
@staticmethod
def about(year):
print('about human {}'.format(year))
a = Person()
print(a.what_is_your_kind())
#Can be called without creating an object
print(Person.what_is_your_kind())#human
print(Person.about(2020))#about human 2020
Recommended Posts