@staticmethod
def _class_name(clas, parts=0):
    """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.
        """
    module = clas.__module__
    if module == '__builtin__':
        fullname = clas.__name__
    else:
        fullname = '%s.%s' % (module, clas.__name__)
    if parts == 0:
        return fullname
    name_parts = fullname.split('.')
    return '.'.join(name_parts[-parts:])
