def esc(s, esc_chars):
 if (not s):
  return u''
 for c in esc_chars:
  esc_str = (u'\\' + c)
  s = s.replace(c, esc_str)
 return s

def esc ( s , esc_chars ) : if ( not s ) : return u'' for c in esc_chars : esc_str = ( u'\\' + c ) s = s . replace ( c , esc_str ) return s
escape special characters .