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


Groups > comp.lang.python > #53452

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

From Zero Piraeus <schesis@gmail.com>
Date 2013-09-01 23:22 -0400
Subject Re: How to split with "\" character, and licence copyleft mirror of (c)
Newsgroups comp.lang.python
Message-ID <mailman.469.1378092168.19984.python-list@python.org> (permalink)

Show all headers | View raw


:

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.

Back to comp.lang.python | Previous | Next | Find similar | Unroll thread


Thread

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

csiph-web