Dan Bishop a écrit :
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
And finally, if you're escaping it to use it for a SQL query, any DB-API
compliant adapter will automatically escape it's params if used correctly.
--
http://mail.python.org/mailman/listinfo/python-list