Raw strings and escaping

Duncan Booth duncan.booth at invalid.invalid
Tue Oct 3 13:54:18 CEST 2006

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

> I presume there was originally some reason for this bizarre behaviour
> - it'd be interesting to know what it is/was, if anyone knows?
See the FAQ for the explanation:


The idea is that if you use raw strings for regular expressions you can 
write things like:

  pattern = r'[\'"]'

if the raw string simply ignored the backslash altogether it would be much 
harder to write regular expressions that contain both sorts of quotes.

More information about the Python-list mailing list