File names with slashes [was Re: error in os.chdir]

Mikhail V mikhailwas at
Sun Jul 1 09:49:32 EDT 2018

[Steven D'Aprano]

> (The same applies to Unix/Linux systems too, of course.) But while you're
> using Python to manipulate files, you should use Python rules, and that
> is "always use forward slashes".
> Is that reasonable?
> Under what circumstances would a user calling open(pathname) in Python
> need to care about backslashes?

Cough cough

On Windows a path is e.g.:

So why should I use forward slashes in a Python literal?
I don't remember any problem caused by using backslashes in paths in Python -
are there problems?
(Apart from the fact that Python dos not have true raw string literals)

So what is reasonable about using forward slashes?
It happens to me that I need to copy-paste real paths like 100 times
a day into scripts - do you propose to convert to forward slashes each time?

More information about the Python-list mailing list