Slashes and Windows (was Re: New to Python.)
peter at engcorp.com
Thu Mar 18 17:40:32 CET 2004
Scott F wrote:
> "Terry Reedy" <tjreedy at udel.edu> wrote in
> news:mailman.126.1079617542.742.python-list at python.org:
>>>You really want to use double backslashes (\\) here or use a raw
>>>string (r'...'). If not, this will eventually bite you.
>>Or forward slashes (/), which avoids the whole problem.
> for file() and similar, forward slashes are great, but try to spawn()
> something and a raw string works better.
The basic rule is that if you are passing the path through the command
line (in effect, using os.system or spawn and friends), you need to use
backslashes, but any other time forward slashes should be fine.
Unfortunately, if you ever get into comparing path strings, and some
have been made with forward slashes, while others used backslashes or
were run through things like os.path.normpath(), then you'll also get
More information about the Python-list