On Sat, 10 Aug 2019 at 12:06, Chris Angelico <ros...@gmail.com> wrote: > > On Sat, Aug 10, 2019 at 6:39 PM Paul Moore <p.f.mo...@gmail.com> wrote: > > There are *many* valid ways to write Windows pathnames in your code: > > > > 1. Raw strings > > 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. > > Please expand on why this is the worst?
I did say it was a matter of opinion, so I'm not going to respond if people say that any of the following is "wrong", but since you asked: 1. Backslash is the native separator, whereas slash is not (see eryk sun's post for *way* more detail). 2. People who routinely use slash have a tendency to forget to use os.sep rather than a literal slash in places where it *does* matter. 3. Using slash, in my experience, ends up with paths with "mixed" separators (os.path.join("C:/work/apps", "foo") -> 'C:/work/apps\\foo') which are messy to deal with, and ugly for the user. 4. If a path with slashes is displayed directly to the user without normalisation, it looks incorrect and can confuse users who are only used to "native" Windows programs. Etc. Paul _______________________________________________ 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/QNAZ4G7VCCBZSFJLUCGH6NTTGW726R6G/