File names with slashes [was Re: error in os.chdir]
steve+comp.lang.python at pearwood.info
Thu Jul 5 02:50:09 EDT 2018
On Thu, 05 Jul 2018 00:56:22 +0300, Mikhail V wrote:
> for the user it is most important to
> *see* and copy-paste the path string exactly as it is displayed
> everywhere else on windows.
So in Windows, you see:
so in Python, we have to use exactly the same path with absolutely no
In Explorer and the open-file dialog of most applications, they will see
paths like this:
directory\file name with spaces
with the extension (.jpg, .pdf, .docx etc) suppressed. So by your
argument, Python needs to accept strings without quotes:
open(directory\file name with spaces, 'r')
and guess which extension you mean.
That would be fun to watch in action.
Python programmers on Macs will see lots of file paths that display with
colons, like this:
and mentally translate it to have a forward slash. Linux programmers will
see paths with spaces and other metacharacters escaped:
directory/file\ name\ with\ spaces.txt
and mentally translate it to remove the backslashes. If they're not
already doing this, they'll surely have to do it soon, when unused
backslash escapes become an error.
Do you believe Python programmers on Windows are especially dumber than
Python programmers on Macs and Linux? I don't, but you seem to want to
coddle them and protect them from having to think about what they're
doing. I think that's patronising of your fellow Windows users.
I'm reminded of a quote by the late Terry Pratchett, an English author,
talking about his experience publishing books in the US. If I remember
correctly, he said that American readers aren't dumb, but American
publishers are convinced that they are.
"Ever since I learned about confirmation bias, I've been seeing
it everywhere." -- Jon Ronson
More information about the Python-list