Raw strings and escaping

Duncan Booth duncan.booth at invalid.invalid
Tue Oct 3 16:17:58 CEST 2006


Jon Ribbens <jon+usenet at unequivocal.co.uk> wrote:

> Well, hardly *much* harder:
> 
>   pattern = r"""foo"""

It means you have to always triple quote your raw strings or know in 
advance of writing the regular expression which of r'', r"", r'''''', 
r"""""" is most appropriate. The way it works at the moment you don't have 
to care, you just write the raw string knowing that with r'' you have to 
escape single quotes, r"" you have to escape double quotes and everything 
works as expected.

Its only when you start trying to use raw strings for things other than 
regular expressions that backslash at the end of the string can be a 
problem.



More information about the Python-list mailing list