def getClass(obj):
    """
    Return the class or type of object 'obj'.
    Returns sensible result for oldstyle and newstyle instances and types.
    """
    if hasattr(obj, '__class__'):
        return obj.__class__
    else:
        return type(obj)

    Return the class or type of object 'obj'.
    Returns sensible result for oldstyle and newstyle instances and types.
    
stackoverflow/venv/lib/python3.6/site-packages/twisted/python/reflect.py