RE: Raw strings and escaping

2006-10-04 Thread Matthew Warren
> -Original Message- > From: > [EMAIL PROTECTED] > [mailto:[EMAIL PROTECTED] > rg] On Behalf Of Scott David Daniels > Sent: 03 October 2006 18:11 > To: python-list@python.org > Subject: Re: Raw strings and escaping > > Matthew Warren wrote: > >

Re: Raw strings and escaping

2006-10-03 Thread Scott David Daniels
Matthew Warren wrote: > Hi, > > I would expect this to work, > > rawstring=r'some things\new things\some other things\' > > But it fails as the last backslash escapes the single quote. Note something many people don't when looking over the string rules: astring = r'some things\new things\som

Re: Raw strings and escaping

2006-10-03 Thread Duncan Booth
Jon Ribbens <[EMAIL PROTECTED]> 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

Re: Raw strings and escaping

2006-10-03 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Duncan Booth 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: > > http://www.python.org/doc/faq/general/#why-can-t-raw-strings-r-s

Re: Raw strings and escaping

2006-10-03 Thread Fredrik Lundh
Matthew Warren wrote: > I would expect this to work, > > rawstring=r'some things\new things\some other things\' > > But it fails as the last backslash escapes the single quote. raw string literals are parsed in exactly the same way as ordinary string literals; it's just the mapping from the stri

Re: Raw strings and escaping

2006-10-03 Thread Duncan Booth
Jon Ribbens <[EMAIL PROTECTED]> 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: http://www.python.org/doc/faq/general/#why-can-t-raw-strings-r-strings-end-with-a-bac

Re: Raw strings and escaping

2006-10-03 Thread Jon Ribbens
In article <[EMAIL PROTECTED]>, Matthew Warren wrote: > I would expect this to work, > > rawstring=r'some things\new things\some other things\' > > But it fails as the last backslash escapes the single quote. String constants in Python are weird - raw strings doubly so. In a raw string, backslas

Re: Raw strings and escaping

2006-10-03 Thread Duncan Booth
"Matthew Warren" <[EMAIL PROTECTED]> wrote: > I would expect this to work, > > rawstring=r'some things\new things\some other things\' > > But it fails as the last backslash escapes the single quote. > > ..although writing this I think I have solved my own problem. Is \' > the only thing escaped

Re: Raw strings and escaping

2006-10-03 Thread Rob Williscroft
Matthew Warren wrote in news:mailman.1152.1159872720.10491.python- [EMAIL PROTECTED] in comp.lang.python: > I would expect this to work, > > rawstring=r'some things\new things\some other things\' It in the docs: http://docs.python.org/ref/strings.html#l2h-14> ... Specifically, a raw string ca

Raw strings and escaping

2006-10-03 Thread Matthew Warren
Hi, I would expect this to work, rawstring=r'some things\new things\some other things\' But it fails as the last backslash escapes the single quote. ..although writing this I think I have solved my own problem. Is \' the only thing escaped in a raw string so you can place ' in a raw string? Alt