S
samslists
Hi...
Here's a weird problem...I'm trying to escape a bunch of data to put
into a database.
Here's what I have:
def escape(string):
"""
Escape both single quotes and blackslashes 'fun\\\\fun'
"""
string = string.replace('\\', '\\\\')
return string
Now the commands in the doctest work when I type them by hand into the
python interpreter!'fun\\\\fun'
But they don't work when I actually run them with doctest:
Failed example:
escape(x)
Expected:
'fun\\fun'
Got:
'fun\x0cun'
Why?
Thanks!
Here's a weird problem...I'm trying to escape a bunch of data to put
into a database.
Here's what I have:
def escape(string):
"""
Escape both single quotes and blackslashes 'fun\\\\fun'
"""
string = string.replace('\\', '\\\\')
return string
Now the commands in the doctest work when I type them by hand into the
python interpreter!'fun\\\\fun'
But they don't work when I actually run them with doctest:
Failed example:
escape(x)
Expected:
'fun\\fun'
Got:
'fun\x0cun'
Why?
Thanks!