'Given a class object, return a fully-qualified name.  This
works for things I\'ve tested in matplotlib so far, but may not
be completely general.'

def class_name(self, cls, parts=0):

    module = cls.__module__
    if (module == '__builtin__'):
        fullname = cls.__name__
    else:
        fullname = ('%s.%s' % (module, cls.__name__))
    if (parts == 0):
        return fullname
    name_parts = fullname.split('.')
    return '.'.join(name_parts[(- parts):])
