Where's your perseverence :-) You should've quadrupled each backslash...
Try this:
a = '-\\n-' # dash, backslash, n, dash
b = regsub.gsub('\\\\n', '\\\\\\\\n', a)
print b
The output is
-\\n-
I.e. dash, backslash, backslash, n, dash.
The reason for the quadrupling is that you need two levels of quoting:
one to cancel the \-interpretation done by string literals, one to
cancel the interpretation done by regular expressions. The same holds
for the substitution expression. Since you want to replace one
literal backslash by two, you end up typing 4 respectively 8...
--Guido van Rossum, CWI, Amsterdam <mailto:Guido.van.Rossum@cwi.nl>
<http://www.cwi.nl/cwi/people/Guido.van.Rossum.html>