@classmethod
def subclass(cls, **kwargs):
    """
        Programmatically generate subclasses of this class.

        The generated subclass will be called <name of this class>_sub unless
        the special parameter __class_name is passed in.
        """
    if '__class_name' in kwargs:
        class_name = kwargs.pop('__class_name')
    else:
        class_name = cls.__name__ + '_sub'
    subcls = type(cls)(class_name, (cls,), kwargs)
    return subcls
