Tim Chase wrote: >>>As an example, I'm aware (through osmosis?) that I can use '/' as >>>a directory separator in filenames on both Unix and Dos. But >>>where is this documented? >> >>in the documentation for your operating system. Python doesn't do >>anything with the filenames. > > > Windows seems to be (occasionally) doing the translation as /F > mentions: > > C:\temp> python > Python 2.4.3 (#69, Mar 29 2006, 17:35:34) [MSC v.1310 32 bit > (Intel)] on win32 > Type "help", "copyright", "credits" or "license" for more > information. > >>> for line in file('subdir/test.txt'): > .... print line.strip() > .... > 1 > 2 > 3 > >>> ^Z > > C:\temp> REM try the same filename convention from dos prompt > C:\temp> type subdir/test.txt > The syntax of the command is incorrect. > C:\temp> REM try with quotes, just in case... > C:\temp> type "subdir/test.txt" > The syntax of the command is incorrect. > C:\temp> notepad subdir/test.txt > C:\temp> REM correctly opened the text file in notepad > > Windows seems to doing the translation inconsistently (I know > that comes as a shock...) > The command line processor parses the slash as a switch delimiter, but the system call interface doesn't know about such refinements and treats forward and backward slashes as filename component separators.
Just the same it's always cleanest to use os.path routines (or similar) to analyze and construct filenames. regards Steve -- Steve Holden +44 150 684 7255 +1 800 494 3119 Holden Web LLC/Ltd http://www.holdenweb.com Skype: holdenweb http://holdenweb.blogspot.com Recent Ramblings http://del.icio.us/steve.holden -- http://mail.python.org/mailman/listinfo/python-list