pylib/uxml/uxpath/ast.py
def to_boolean(obj):
    '''
    Cast an arbitrary sequence to a boolean type
    '''
    #if hasattr(obj, '__iter__'):
    if isinstance(obj, LiteralWrapper):
        val = obj.obj
    elif isinstance(obj, Iterable) and not isinstance(obj, str):
        val = next(obj, None)
    else:
        val = obj
    if val is None:
        yield False
    elif isinstance(val, bool):
        yield val
    elif isinstance(val, str):
        yield bool(str)
    elif isinstance(val, node):
        yield True
    elif isinstance(val, float) or isinstance(val, int):
        yield bool(val)
    else:
        raise RuntimeError('Unknown type for boolean conversion: {}'.format(val))
def to_boolean(obj):
    '''
    Cast an arbitrary sequence to a boolean type
    '''
    #if hasattr(obj, '__iter__'):
    if isinstance(obj, LiteralWrapper):
        val = obj.obj
    elif isinstance(obj, Iterable) and not isinstance(obj, str):
        val = next(obj, None)
    else:
        val = obj
    if val is None:
        yield False
    elif isinstance(val, bool):
        yield val
    elif isinstance(val, str):
        yield bool(str)
    elif isinstance(val, node):
        yield True
    elif isinstance(val, float) or isinstance(val, int):
        yield bool(val)
    else:
        raise RuntimeError('Unknown type for boolean conversion: {}'.format(val))
Cast an arbitrary sequence to a boolean type