Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #53452 > unrolled thread

Re: How to split with "\" character, and licence copyleft mirror of (c)

Started byZero Piraeus <schesis@gmail.com>
First post2013-09-01 23:22 -0400
Last post2013-09-01 23:22 -0400
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: How to split with "\" character, and licence copyleft mirror of (c) Zero Piraeus <schesis@gmail.com> - 2013-09-01 23:22 -0400

#53452 — Re: How to split with "\" character, and licence copyleft mirror of (c)

FromZero Piraeus <schesis@gmail.com>
Date2013-09-01 23:22 -0400
SubjectRe: How to split with "\" character, and licence copyleft mirror of (c)
Message-ID<mailman.469.1378092168.19984.python-list@python.org>
:

On 1 September 2013 22:40, Tim Roberts <timr@probo.com> 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'\')

Acually, that doesn't work:

    >>> a = r'E:\Dropbox\jjfsdjjsdklfj\sdfjksdfkjslkj\flute.wav'
    >>> a.split('\')
      File "<stdin>", line 1
        a.split('\')
                   ^
    SyntaxError: EOL while scanning string literal

... because you can't end a raw string with a backslash:

http://docs.python.org/3/faq/design.html#why-can-t-raw-strings-r-strings-end-with-a-backslash

 -[]z.

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web