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

Mikhail V mikhailwas at
Wed Jul 4 16:25:23 EDT 2018

Joe Pfeiffer wrote:

>> On Windows a path is e.g.:
>> C:\programs\util\
>> 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?

> That's what started the thread -- using backslashes caused a \a to be
> interpreted as a special character instead of two characters in the
> path.

Yes, and the answer was a week ago: just put "r" before  the string.

And it worked till now. So why should I replace backslashes with
forward slashes?
There is one issue that I can't write \ on the end:

But since I know it's a path and not a file, I just write without trailing \.

More information about the Python-list mailing list