1.# 按照类的继承顺序,找下一个.
class Foo(object):
def f1(self):
super().f1()
print('3个功能')
class Bar(object):
def f1(self):
print('6个功能')
class Info(Foo,Bar):
pass
# obj = Foo()
# obj.f1() #报错AttributeError: 'super' object has no attribute 'f1'
obj = Info()
obj.f1() #6个功能
#3个功能
2.class StarkConfig(object):
list_display = [1,4]
s1 = StarkConfig()
s2 = StarkConfig()
s1.list_display.append(3)
print(s1.list_display) #[1, 4, 3]
s2.list_display.append(9)
print(s2.list_display) #[1, 4, 3, 9]
# class StarkConfig(object):
# list_display = 'dd'
# s1 = StarkConfig()
# s2 = StarkConfig()
# s1.list_display = 'tt'
# print(s1.list_display) #'tt'
# print(s2.list_display) #'dd'
class StarkConfig(object):
list_display = 'dd'
s1 = StarkConfig()
s2 = StarkConfig()
StarkConfig.list_display = 'tt'
print(s1.list_display) #'tt'
print(s2.list_display) #'tt'