open filename with spaces in path

Michael Robertson mcrobertson at hotmail.com
Tue May 6 18:36:35 EDT 2008


I'm having trouble opening a file in linux, whose path has spaces in it.

$ mkdir my\ test
$ echo test > my\ test/test.txt
$ python

 >>> open('./my test/test.txt')
Exception
 >>> open('./my\\ test/test.txt')
Exception

but yet...

 >>> import os
 >>> os.chdir('./my test')
 >>> open('./test')

works just fine.



More information about the Python-list mailing list