(str)
return str.replace('\\', '\\\\').replace('"', '\\"')
Prepare string to be used in a quoted string.

    Turns backslash and double quote characters into quoted pairs.  These
    are the only characters that need to be quoted inside a quoted string.
    Does not add the surrounding double quotes.
Prepare string to be used in a quoted string.
Prepare string to be used in a quoted string .
def quote(str):
    """Prepare string to be used in a quoted string.

    Turns backslash and double quote characters into quoted pairs.  These
    are the only characters that need to be quoted inside a quoted string.
    Does not add the surrounding double quotes.
    """
    return str.replace('\\', '\\\\').replace('"', '\\"')
def quote ( str ) : return str . replace ( '\\' , '\\\\' ) . replace ( '"' , '\\"' )