(pattern)
Escape special characters in a string.
Escape special characters in a string.
Escape special characters in a string .
def escape(pattern):
    """
    Escape special characters in a string.
    """
    if isinstance(pattern, str):
        return pattern.translate(_special_chars_map)
    else:
        pattern = str(pattern, 'latin1')
        return pattern.translate(_special_chars_map).encode('latin1')
def escape ( pattern ) : if isinstance ( pattern , str ) : return pattern . translate ( _special_chars_map ) else : pattern = str ( pattern , 'latin1' ) return pattern . translate ( _special_chars_map ) . encode ( 'latin1' )