Raw strings and escaping
Matthew.Warren at Digica.com
Wed Oct 4 15:49:20 CEST 2006
> -----Original Message-----
> python-list-bounces+matthew.warren=digica.com at python.org
> [mailto:python-list-bounces+matthew.warren=digica.com at python.o
> rg] On Behalf Of Scott David Daniels
> Sent: 03 October 2006 18:11
> To: python-list at python.org
> Subject: Re: Raw strings and escaping
> 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\some other things' '\\'
> gives you exactly what you want, doesn't imply a string concatenation
> at run time, and various other things. Two strings in succession are
> concatenated at source translation time.
Thanks for this and the other explanations.
And you hit the nail on the head with this;
>By the way, I renamed the result from being rawstring. It
> gives people
> bad intuitions to refer to some strings as "raw" when what you really
> mean is that the notation you are using is a "raw" notation for a
> perfectly normal string.
This is exactly the mistake I had made. I was assuming I was dealing
with 'raw' in this context
This email is confidential and may be privileged. If you are not the intended recipient please notify the sender immediately and delete the email from your computer.
You should not copy the email, use it for any purpose or disclose its contents to any other person.
Please note that any views or opinions presented in this email may be personal to the author and do not necessarily represent the views or opinions of Digica.
It is the responsibility of the recipient to check this email for the presence of viruses. Digica accepts no liability for any damage caused by any virus transmitted by this email.
UK: Phoenix House, Colliers Way, Nottingham, NG8 6AT UK
Reception Tel: + 44 (0) 115 977 1177
Support Centre: 0845 607 7070
Fax: + 44 (0) 115 977 7000
SOUTH AFRICA: Building 3, Parc du Cap, Mispel Road, Bellville, 7535, South Africa
Tel: + 27 (0) 21 957 4900
Fax: + 27 (0) 21 948 3135
More information about the Python-list