Re: Correct syntax for pathological re.search()

Liste des GroupesRevenir à cl python 
Sujet : Re: Correct syntax for pathological re.search()
De : jon+usenet (at) *nospam* unequivocal.eu (Jon Ribbens)
Groupes : comp.lang.python
Date : 07. Oct 2024, 16:43:59
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <slrnvg80dv.5tq2.jon+usenet@raven.unequivocal.eu>
References : 1 2 3 4
User-Agent : slrn/1.0.3 (Linux)
On 2024-10-07, Stefan Ram <ram@zedat.fu-berlin.de> wrote:
"Michael F. Stemper" <michael.stemper@gmail.com> wrote or quoted:
For now, I'll use the "r" in a cargo-cult fashion, until I decide which
syntax I prefer. (Is there any reason that one or the other is preferable?)
>
  I'd totally go with the r-style notation!
>
  It's got one bummer though - you can't end such a string literal with
  a backslash. But hey, no biggie, you could use one of those notations:
>
  main.py
>
path = r'C:\Windows\example' + '\'
>
print( path )
   
path = r'''
C:\Windows\example\
'''.strip()
>
print( path )
>
  stdout
>
C:\Windows\example\
C:\Windows\example\
>
  .

... although of course in this example you should probably do neither of
those things, and instead do:

    from pathlib import Path
    path = Path(r'C:\Windows\example')

since in a Path the trailing '\' or '/' is unnecessary. Which leaves
very few remaining uses for a raw-string with a trailing '\'...

Date Sujet#  Auteur
7 Oct 24 * Correct syntax for pathological re.search()28Michael F. Stemper
7 Oct 24 +* Re: Correct syntax for pathological re.search()6Stefan Ram
7 Oct 24 i`* Re: Correct syntax for pathological re.search()5Michael F. Stemper
7 Oct 24 i `* Re: Correct syntax for pathological re.search()4Stefan Ram
7 Oct 24 i  +- Re: Correct syntax for pathological re.search()1Jon Ribbens
8 Oct 24 i  `* Re: Correct syntax for pathological re.search()2Pieter van Oostrum
9 Oct 24 i   `- Re: Correct syntax for re.search() (Posting On Python-List Prohibited)1Lawrence D'Oliveiro
8 Oct 24 +- Re: Correct syntax for pathological re.search()1Karsten Hilbert
8 Oct 24 +- Re: Correct syntax for pathological re.search()1MRAB
8 Oct 24 +* Re: Correct syntax for pathological re.search()3MRAB
8 Oct 24 i`* Re: Correct syntax for pathological re.search()2Stefan Ram
8 Oct 24 i `- Re: Correct syntax for pathological re.search()1Stefan Ram
8 Oct 24 +* Re: Correct syntax for pathological re.search()4Karsten Hilbert
8 Oct 24 i`* Re: Correct syntax for pathological re.search()3Alan Bawden
9 Oct 24 i +- Re: Correct syntax for pathological re.search()1MRAB
9 Oct 24 i `- Re: Correct syntax for pathological re.search()1Karsten Hilbert
11 Oct 24 +- Re: Correct syntax for pathological re.search()1<avi.e.gross
12 Oct 24 +- Re: Correct syntax for pathological re.search()1MRAB
12 Oct 24 +* Re: Correct syntax for pathological re.search()2Peter J. Holzer
12 Oct 24 i`- Re: Correct syntax for pathological re.search()1Stefan Ram
12 Oct 24 +- Re: Correct syntax for pathological re.search()1Thomas Passin
12 Oct 24 +- Re: Correct syntax for pathological re.search()1<avi.e.gross
12 Oct 24 +- Re: Correct syntax for pathological re.search()1Thomas Passin
13 Oct 24 +- Re: Correct syntax for pathological re.search()1Stefan Ram
18 Oct 24 `* Re: Correct syntax for pathological re.search()4Peter J. Holzer
19 Oct 24  `* Re: Correct syntax for pathological re.search()3jak
21 Oct 24   `* Re: Correct syntax for pathological re.search()2Peter J. Holzer
21 Oct 24    `- Re: Correct syntax for pathological re.search()1Stefan Ram

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal