registry = {}

def register(cls):
    registry[cls.__name__] = cls()
return cls


class MetaClass(type):

    def __new__(cls, clsname, bases, attrs):
        newclass = super(cls, MetaClass).__new__(cls, clsname, bases, attrs)
register(newclass)
return newclass


class Base(object):
    pass


class ClassWithMeta(Base, metaclass=MetaClass):
    pass

def __init__(self):
    super(ClassWithMeta, self).__init__()


@register
class DecoratedClass(Base):

    def __init__(self):
        super(DecoratedClass, self).__init__()
Как автоматически зарегистрировать класс, когда он определен