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

2013-09-02 Thread Chris Angelico
On Tue, Sep 3, 2013 at 6:22 AM, Ethan Furman et...@stoneleaf.us wrote:
 In a raw string, the backslash is buggy (IMNSHO) when it's the last
 character.

It's an inevitable consequence of using the backslash to escape the
quote character. If instead, a raw string doubled the quote character
(like in REXX), it'd need no other escape:

r'\' -- '\\'
r -- '

Too late to change now.

ChrisA
-- 
http://mail.python.org/mailman/listinfo/python-list


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

2013-09-01 Thread Zero Piraeus
:

On 1 September 2013 22:40, Tim Roberts t...@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.
-- 
http://mail.python.org/mailman/listinfo/python-list