def implements(obj, interface):
    """Return true if the give object (maybe an instance or class) implements
    the interface.
    """
    kimplements = getattr(obj, '__implements__', ())
    if not isinstance(kimplements, (list, tuple)):
        kimplements = kimplements,
    for implementedinterface in kimplements:
        if issubclass(implementedinterface, interface):
            return True
    return False
