On Jun 24, 4:04 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
> Are you trying to escape for a regular expression?
>
> Just do re.escape().
>
> >>> print re.escape('Happy')
> Happy
> >>> print re.escape("Frank's Diner")
>
> Frank\'s\ Diner
>
> If you're escaping for URLs, there's urllib2.quote(), for a command
> line, use subprocess.list2cmdline.

And if you're escaping for string literals in Python (or C and its
descendants), you can do:

>>> print "Frank's Diner".encode('string-escape')
Frank\'s Diner

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to