return the handler for the object type

def handler_for(obj):
    """return the handler for the object type"""
    for handler_type in handlers:
        if isinstance(obj, handler_type):
            return handlers[handler_type]

    try:
        for handler_type in handlers:
            if issubclass(obj, handler_type):
                return handlers[handler_type]
    except TypeError:
        # if obj isn't a class, issubclass will raise a TypeError
        pass