The format of filename

Tim Chase python.list at tim.thechases.com
Tue Oct 24 11:29:08 EDT 2006


>> 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...)

-tkc








More information about the Python-list mailing list