is this a Python bug?
scarblac-spamtrap at pino.selwerd.nl
Thu Feb 17 11:11:14 CET 2000
Steve Holden wrote in comp.lang.python:
> What on Earth does "backslashes are still used to quote the
> folowing character, but all backslashes are left in the string"
> mean? I am sure it means something, but I can't tell what.
In a normal string between '', you need to escape inner 's:
'\'' is the string: '
In raw strings, the ' still needs to be escaped, but the \ is left in:
r'\'' is the string: \'
You can't have a raw string with only one \ in it, because:
r'\' is an error, the \ escapes the ', and the string doesn't end
r'\\' is the string: \\
The \ is escaped in the last one, but the escaping \ is left in the string.
In normal strings, it's simple:
'\\' is the string: \
The first backslash escapes the second, and is then removed from the string.
There's nothing really magic about it.
Remco Gerlich, scarblac at pino.selwerd.nl
11:06am up 85 days, 17:11, 6 users, load average: 0.20, 0.07, 0.07
More information about the Python-list