On 8/10/2019 12:19 PM, Guido van Rossum wrote:
Regular expressions.

I assume that is in response to the "good use for \" escape" question?

But can't you just surround them with ' instead of " ?  Or  ''' ?


On Sat, Aug 10, 2019 at 12:12 Glenn Linderman <v+pyt...@g.nevcal.com <mailto:v%2bpyt...@g.nevcal.com>> wrote:

    On 8/10/2019 11:16 AM, Terry Reedy wrote:
    On 8/10/2019 4:33 AM, Paul Moore wrote:

    (Side issue)

    This deserves its own thread.

    As a Windows developer, who has seen far too many cases where
    use of
    slashes in filenames implies a Unix-based developer not thinking
    sufficiently about Windows compatibility, or where it leads to
    people
    hard coding '/' rather than using os.sep (or better, pathlib), I
    strongly object to this characterisation. Rather, I would simply
    say
    "to make Windows users more aware of the clash in usage between
    backslashes in filenames and backslashes as string escapes".

    There are *many* valid ways to write Windows pathnames in your
    code:

    1. Raw strings

    As pointed out elsewhere, Raw strings have limitations, paths
    ending in \ cannot be represented, and such do exist in various
    situations, not all of which can be easily avoided... except by
    the "extra character contortion" of "C:\directory\ "[:-1]  (does
    someone know a better way?)

    It would be useful to make a "really raw" string that doesn't
    treat \ special in any way. With 4 different quoting possibilities
    ( ' " ''' """ ) there isn't really a reason to treat \ special at
    the end of a raw string, except for backward compatibility.

    I wonder how many raw strings actually use the \"  escape
    productively? Maybe that should be deprecated too! ?  I can't
    think of a good and necessary use for it, can anyone?

    Or invent "really raw" in some spelling, such as rr"c:\directory\"
    or e for exact, or x for exact, or <your favorite character
    here>"c:\directory\"

    And that brings me to the thought that if   \e  wants to become an
    escape for escape, that maybe there should be an "extended escape"
    prefix... if you want to use more escapes, define   ee"string
    where \\ can only be used as an escape or escaped character, \e
    means the ASCII escape character, and \ followed by a character
    with no escape definition would be an error."

    Of course "extended escape" could be spelled lots of different
    ways too, but not the same way as "really raw" :)

    2. Doubling the backslashes
    3. Using pathlib (possibly with slash as a directory separator,
    where
    it's explicitly noted as a portable option)
    4. Using slashes

    IMO, using slashes is the *worst* of these. But this latter is a
    matter of opinion - I've no objection to others believing
    differently,
    but I *do* object to slashes being presented as the only option, or
    the recommended option without qualification.

    Perhaps Python Setup and Usage, 3. Using Python on Windows,
    should have a section of file paths, at most x.y.z, so visible in
    the TOC listed by https://docs.python.org/3/using/index.html


    _______________________________________________
    Python-Dev mailing list -- python-dev@python.org
    <mailto:python-dev@python.org>
    To unsubscribe send an email to python-dev-le...@python.org
    <mailto:python-dev-le...@python.org>
    https://mail.python.org/mailman3/lists/python-dev.python.org/
    Message archived at
    
https://mail.python.org/archives/list/python-dev@python.org/message/5MZAXJJYKNMQAS63QW4HS2TUPMQH7LSL/

--
--Guido (mobile)

_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at 
https://mail.python.org/archives/list/python-dev@python.org/message/BZDAXLX2IQTIUT2W47SFI2CJTZSPXY2V/

Reply via email to