def decorator(cls):
        """Return a new nametuple-based subclass of cls."""
        # Using super() (i.e. the MRO) makes this work correctly.
        bases = (namedtuple(cls.__name__, fields), cls)
        namespace = {'__doc__': cls.__doc__, '__slots__': (),
                     'with_defaults': with_defaults}
        return type(cls.__name__, bases, namespace)
Return a new nametuple-based subclass of cls.
recipes/Python/578456_class_decorator_creating_named/recipe-578456.py