Tom Plunket wrote: > John Machin wrote: > > > If you were to write 'c:\temp\book1.csv', it would blow up ... because > > \t -> tab and \b -> backspace. Get into the habit of *always* using raw > > strings r'C:\Temp\Book1.csv' for Windows file names (and re patterns). > > You could use double backslashing 'C:\\Temp\\Book1.csv' but it's > > uglier. > > ...alternatively you can just use 'unix slashes', e.g. > 'c:/temp/book1.csv', since those work just fine 'cause the Windows > APIs deal with them properly.
Not all APIs do the right thing. If you fire up the cmd.exe shell and feed it slashes as path separators, it barfs. Example: C:\junk>dir c:/junk/*.bar Invalid switch - "junk". Hence the advice to use rawstrings with backslashes -- they work under all circumstances. -- http://mail.python.org/mailman/listinfo/python-list