def quote_if_necessary(s):
    """Quotes arbitrary string into quoted-string."""

    quote = False
    if s == '':
        return '""'

    result = []
    for c in s:
        if c == '"' or _SEPARATORS in c or _is_ctl(c) or not _is_char(c):
            quote = True

        if c == '"' or _is_ctl(c):
            result.append('\\' + c)
        else:
            result.append(c)

    if quote:
        return '"' + ''.join(result) + '"'
    else:
        return ''.join(result)
dataset/ETHPy150Open google/pywebsocket/mod_pywebsocket/http_header_util.py/quote_if_necessary/swapped operands of `in`