File names with slashes [was Re: error in os.chdir]
pfeiffer at cs.nmsu.edu
Wed Jul 4 11:03:29 EDT 2018
Mikhail V <mikhailwas at gmail.com> writes:
> [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?
That's what started the thread -- using backslashes caused a \a to be
interpreted as a special character instead of two characters in the
More information about the Python-list