class Decorator: def __init__(self, *args, **kwargs): print('D.__init__') self.args = args self.kwargs = kwargs def __call__(self, cls): print('D.__call__') def wrapper(*args, **kwargs): print('wrapper') cls(*args, **kwargs) return wrapper @Decorator(1, 2) class A: def __new__(cls, *args, **kwargs): print('A.__new__') return object.__new__(cls) def __init__(self, *args, **kwargs): print('A.__init__') self.args = args self.kwargs = kwargs A() A('1') A('2')
|