RE: Re[2]: backslashes and r-strings r"abc"
"Mark Hahn" <[email protected]> Mon, 26 Jul 2004 21:33:09 -0700
| Newsgroups | gmane.comp.lang.prothon.user |
|---|---|
| Message-ID | <000201c47392$d1d6ef00$0d01a8c0@MarkVaio> |
Lenard Lindstrom wrote:
> > One thing that bothers me about Python's r-strings is that they are
> > supposed to pass backslashes but they throw an exception if
> you have a
> > backslash as the last character. This makes them useless
> in one place
> > I've always wanted to use them:
> >
> > r"c:\windows directory\" # throws Python exception
> >
> > So maybe Prothon could at least fix that problem. Does
> anyone see any
> > reason to preserve Python's restriction on not having a
> backslash as
> > the last character of a r-string?
> >
> Go ahead. Backslash for line continuation in a raw string is
> broken for both Prothon and Python anyways:
>
> Python 2.4a1 (#54, Jul 8 2004, 11:30:13) [MSC v.1310 32 bit
> (Intel)] on win32 Type "help", "copyright", "credits" or
> "license" for more information.
> >>> r"abc\
> ... def"
> 'abc\\\ndef'
How can a backslash do continuation if backslashes are disabled in a
r-string?
> Prothon 0.1 Interactive Console, Build 742, Jul 15 2004
> (Ctrl-D to exit)
> O>> r"abc\
> ... def"
> Lexical error: unterminated quote string
>
> By the way, what happened to string literal concatenation? I
> thought it was on the todo list.
It IS on the to-do list. :-) I've been busy writing my talk and rewriting
the object code preparing for the new garbage collector.
> Prothon 0.1 Interactive Console, Build 742, Jul 15 2004
> (Ctrl-D to exit)
> O>> print("abc" "def")
>
> Parse Error: expecting `')'' or `',''
> --- col: 18
>
> Uncaught exception:
> Parse Error.
>
> String literal concatenation replaced almost all uses of line
> continuation within strings unnecessary. The only use I have
> found for line continuation is at the start of triple-quoted strings.
>
> print("""\
> The following is arranged
> as to how it will appear.
> """)
The you shouldn't care if they don't work in r-strings.