class ChattyType(type):

    def __new__(cls, name, bases, dct):
        print('Allocating memory for class', name)
return type.__new__(cls, name, bases, dct)

def __init__(cls, name, bases, dct):
    print("Init'ing (configuring) class", name)
super(ChattyType, cls).__init__(name, bases, dct)
X = ChattyType('X', (), {'foo': lambda self: 'foo'})
X, X().foo()
Прототипное программирование на Python