human
Complete this python program:
def attr(accessing_obj, accessed_obj, *args, **kwargs):
assistant
#Here is the Python program you requested.

    """Usage:
    attr(attrname)
    attr(attrname, value)
    attr(attrname, value, compare=type)
    where compare\s type is one of (eq,gt,lt,ge,le,ne) and signifies
    how the value should be compared with one on accessing_obj (so
    compare=gt means the accessing_obj must have a value greater than
    the one given).
    Searches attributes *and* properties stored on the accessing_obj.
    if accessing_obj has a property "obj", then this is used as
    accessing_obj (this makes this usable for Commands too)
    The first form works like a flag - if the attribute/property
    exists on the object, the value is checked for True/False. The
    second form also requires that the value of the attribute/property
    matches. Note that all retrieved values will be converted to
    strings before doing the comparison.
    """
    if (not args):
        return False
    attrname = args[0].strip()
    value = None
    if (len(args) > 1):
        value = args[1].strip()
    compare = 'eq'
    if kwargs:
        compare = kwargs.get('compare', 'eq')
    def valcompare(val1, val2, typ='eq'):
        'compare    based    on    type'
        try:
            return CF_MAPPING.get(typ, CF_MAPPING['default'])(val1, val2)
        except Exception:
            return False
    if hasattr(accessing_obj, 'obj'):
        accessing_obj = accessing_obj.obj
    if hasattr(accessing_obj, attrname):
        if value:
            return valcompare(str(getattr(accessing_obj, attrname)), value, compare)
        return bool(getattr(accessing_obj, attrname))
    if (hasattr(accessing_obj, 'attributes') and accessing_obj.attributes.has(attrname)):
        if value:
            return (hasattr(accessing_obj, 'attributes') and valcompare(accessing_obj.attributes.get(attrname), value, compare))
        return bool(accessing_obj.attributes.get(attrname))
    return False