Extract the type string from str(type(obj)) to remove the "<class..." bit.

def extract_type(s):
    """Extract the type string from str(type(obj)) to remove the "<class..." bit."""
    r = re.compile(r"<class '(.*)'>", re.MULTILINE | re.IGNORECASE)
    try:
        m = r.match(str(s)).group(1)
    except (IndexError, AttributeError) as e:
        m = None

    return m