Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #53526
| Date | 2013-09-02 13:22 -0700 |
|---|---|
| From | Ethan Furman <ethan@stoneleaf.us> |
| Subject | Re: How to split with "\" character, and licence copyleft mirror of © |
| References | <c795fae4-2b38-4d81-a552-a69febdac0c0@googlegroups.com> <r4u729t37qllb5dfcc7qmq5hpsi8apl6gf@4ax.com> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.513.1378154810.19984.python-list@python.org> (permalink) |
On 09/01/2013 07:40 PM, Tim Roberts wrote:
>
> Another altrnative is to use "raw" strings, in which backslashes are not
> interpreted:
> a = r'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav'
> a.split(r'\')
Not quite.
--> r'\'
File "<stdin>", line 1
r'\'
^
SyntaxError: EOL while scanning string literal
In a raw string, the backslash is buggy (IMNSHO) when it's the last character. Given the above error, you might think
that to get a single-quote in a string delimited by single-quotes that you would use r'\'', but no:
--> r'\''
"\\'"
you get a backslash and a single-quote. And if you try to escape the backslash to get only one?
--> r'\\'
'\\\\'
You get two. Grrrr.
--
~Ethan~
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
How to split with "\" character, and licence copyleft mirror of © materile11@gmail.com - 2013-09-01 17:03 -0700
Re: How to split with "\" character, and licence copyleft mirror of © Cameron Simpson <cs@zip.com.au> - 2013-09-02 10:23 +1000
Re: How to split with "\" character, and licence copyleft mirror of © Tim Chase <python.list@tim.thechases.com> - 2013-09-01 19:34 -0500
Re: How to split with "\" character, and licence copyleft mirror of © materile11@gmail.com - 2013-09-01 21:20 -0700
Re: How to split with "\" character, and licence copyleft mirror of © Tim Chase <python.list@tim.thechases.com> - 2013-09-01 19:40 -0500
Re: How to split with "\" character, and licence copyleft mirror of © Tim Roberts <timr@probo.com> - 2013-09-01 19:40 -0700
Re: How to split with "\" character, and licence copyleft mirror of © Ethan Furman <ethan@stoneleaf.us> - 2013-09-02 13:22 -0700
Re: How to split with "\" character, and licence copyleft mirror of © Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2013-09-03 02:06 +0000
Re: How to split with "\" character, and licence copyleft mirror of © Tim Chase <python.list@tim.thechases.com> - 2013-09-03 05:31 -0500
Re: How to split with "\" character, and licence copyleft mirror of © random832@fastmail.us - 2013-09-03 14:31 -0400
Re: How to split with "\" character, and licence copyleft mirror of © Tim Roberts <timr@probo.com> - 2013-09-05 20:33 -0700
Re: How to split with "\" character, and licence copyleft mirror of � Terry Reedy <tjreedy@udel.edu> - 2013-09-06 02:15 -0400
Re: How to split with "\" character, and licence copyleft mirror of © random832@fastmail.us - 2013-09-06 09:29 -0400
Re: How to split with "\" character, and licence copyleft mirror of � Fábio Santos <fabiosantosart@gmail.com> - 2013-09-11 11:16 +0100
csiph-web