import six


def subclasses_of(class_, it, exclude=None):
    """Extract the subclasses of a class from a module, dict, or iterable.

    Return a list of subclasses found. The class itself will not be included.
    This is useful to collect the concrete subclasses of an abstract base
    class.

    ``class_`` is a class.

    ``it`` is a dict or iterable. If a dict is passed, examine its values,
    not its keys. To introspect the current module, pass ``globals()``. To
    introspect another module or namespace, pass
    ``vars(the_module_or_namespace)``.

    ``exclude`` is an optional list of additional classes to ignore. 
    This is mainly used to exclude abstract subclasses.
    """
    if isinstance(it, dict):
        it = six.itervalues(it)
    ignore = [class_]
    if exclude:
        ignore.extend(exclude)
    class_types = six.class_types
    ret = []
    return [x for x in it if isinstance(x, class_types) and 
        issubclass(x, class_) and x not in ignore]