def escape(s):
    """Replace potential special characters with escaped version.

    For example, \\n => \\\\n and \\t => \\\\t

    :param s: string to escape
    """
    return s.replace('\n', '\\n').replace('\t', '\\t').replace('\r', '\\r')
