import six


def _tostr(val):
    """
    >>> _tostr('foo')
    'foo'
    >>> isinstance(_tostr(u'foo'), six.text_type)
    True
    >>> _tostr(10)
    '10'
    >>> _tostr(True)
    '1'
    >>> _tostr(False)
    '0'
    """
    if isinstance(val, six.string_types):
        return val
    if isinstance(val, bool):
        return str(int(val))
    return str(val)