运行这个代码,你会发现会打印出 new 一下
class SettingMeta(type):
def __new__(cls, name, bases, attrs):
print('new 一下')
return super().__new__
class Setting(object, metaclass=SettingMeta):
def __init__(self):
print('初始化')
运行这个代码,你会发现会打印出 new 一下
class SettingMeta(type):
def __new__(cls, name, bases, attrs):
print('new 一下')
return super().__new__
class Setting(object, metaclass=SettingMeta):
def __init__(self):
print('初始化')