Re: Re: backslashes and r-strings r"abc"

Lenard Lindstrom <[email protected]> Fri, 30 Jul 2004 12:54:19 -0700 (Pacific Daylight Time)
Newsgroups gmane.comp.lang.prothon.user
Message-ID <Mahogany-0.66.0-4294835251-20040730-130728.00@pop3.norton.antivirus>
On Thu, 29 Jul 2004 08:40:07 -0700 Mark Hahn <[email protected]> wrote:

> Lenard Lindstrom wrote:
> 
> >> No wonder I didn't understand what "Python in a nutshell" was
> >> explaining. It makes no sense whatsoever.  What in the hell was
> >> Guido thinking?
> >>
> > Regular expressions. Martin Christensen mentioned only using "r"
> > strings for regular expressions. That is where I use them too. A
> > backslash-quote in a pattern will match a quote in a string. And two
> > backslashes are required
> > to match a single backslash. Thus the even number of backslashes at
> > the
> > end of an "r" string rule. So "r" for "regular expression" makes
> > sense; "r" for "raw" does not.
> 
> Oh, I understand now.  He is pre-checking to make sure the string will be
> legal later when used in the regex.  That is kind of silly since it will be
> checked again right away in the regex processing.
> 
> So our new definition is losing that regex pre-check but gaining the
> flexibility of using the r-string for other purposes like windows paths.  I
> think we are making the right decision.
> 
Not for checking, just for convenience. One can type a regular expression as a
single "r" string without having to escape the re escape, the backslash, or
use string literal concatenation to include the quote character. Windows file
paths were simply not considered.

Lenard Lindstrom
<[email protected]>