def __new__(meta_class, class_name, bases, class_dict, **kw_arguments):
    """
        Create a new type object, for example through a 'class' statement.

        Behaves like a class method and is called before __init__().
        """
    if kw_arguments:
        specialized_meta_class = meta_class.__specialize(kw_arguments)
        specialized_bases = []
        for base in bases:
            if base.__class__ is meta_class:
                specialized_bases.append(specialized_meta_class.__new__(
                    specialized_meta_class, base.__plain_name__, base.
                    __bases__, base.__dict__))
            else:
                specialized_bases.append(base)
        return specialized_meta_class.__new__(specialized_meta_class,
            class_name, tuple(specialized_bases), class_dict)
    else:
        extended_name = meta_class.__template_name(class_name, meta_class.
            __parameters__, meta_class.__parameter_map__)
        extended_dict = meta_class.__parameter_map__.copy()
        extended_dict.update(class_dict)
        extended_dict['__plain_name__'] = class_name
        return type.__new__(meta_class, extended_name, bases, extended_dict)
