def quote_ps_string(s):
 s = s.replace('\\', '\\\\')
 s = s.replace('(', '\\(')
 s = s.replace(')', '\\)')
 s = s.replace("'", '\\251')
 s = s.replace('`', '\\301')
 s = re.sub('[^ -~\\n]', (lambda x: ('\\%03o' % ord(x.group()))), s)
 return s

def quote_ps_string ( s ) : s = s . replace ( '\\' , '\\\\' ) s = s . replace ( '(' , '\\(' ) s = s . replace ( ')' , '\\)' ) s = s . replace ( "'" , '\\251' ) s = s . replace ( '`' , '\\301' ) s = re . sub ( '[^ -~\\n]' , ( lambda x : ( '\\%03o' % ord ( x . group ( ) ) ) ) , s ) return s
quote dangerous characters of s for use in a postscript string constant .