os.path.join doubt

Ethan Furman ethan at stoneleaf.us
Thu Feb 3 10:58:55 EST 2011


Steven D'Aprano wrote:
> BTW, Windows accepts / as well as \ as a path separator. You will have 
> far fewer headaches if you use that.

Just because Windows accepts / doesn't make it a good idea...

Python 2.5.4 (r254:67916, Dec 23 2008, 15:10:54) [MSC v.1310 32 bit 
(Intel)] on win32
Type "help", "copyright", "credits" or "license" for more information.
--> from glob import glob
--> print '\n'.join(glob('c:/temp/*'))
c:/temp\0C2O0007.TMP
c:/temp\27421
c:/temp\3K540007.TMP
c:/temp\AIF19780_01B_BACKUP.DBF
c:/temp\Arabic.bin
c:/temp\au-descriptor-1.6.0_23-b71.xml
c:/temp\AUCHECK_CORE.txt
c:/temp\AUCHECK_PARSER.txt
c:/temp\bar.py
c:/temp\bar.pyc
c:/temp\caller.py
c:/temp\caller.pyc
c:/temp\choose_python.pdf
c:/temp\CMD19639_B_BACKUP.DBF
c:/temp\COA.pdf
c:/temp\compress.py
c:/temp\compress.pyc
c:/temp\control.dbf
c:/temp\control.FPT

Or is there an option I'm missing so backslashes are not returned by 
stdlib functions?

~Ethan~



More information about the Python-list mailing list