Need help dealing with spaces in NT paths.

Josef Betancourt josefb at csi.com
Wed Nov 17 07:40:48 EST 1999


Maybe my typing is really off today, but it don't work:

>>> os.system('dir "program files"')

 Volume in drive C is CDRIVE
 Volume Serial Number is 2E50-0FE9
 Directory of C:\WINDOWS

File not found
                      362,876,928 bytes free
0
>>>

----- Original Message ----- 
From: Fredrik Lundh <fredrik at pythonware.com>
To: T. C. Mits <71351.356 at compuserve.com>
Cc: Python Mailing List <python-list at cwi.nl>
Sent: Wednesday, November 17, 1999 5:43 AM
Subject: Re: Need help dealing with spaces in NT paths.


> 
> T. C. Mits <71351.356 at compuserve.com> wrote:
> > A simple example of the difficulty is:
> > 
> > >>> os.system(r'"dir Program Files"')
> > Bad command or file name
> > 0
> > >>>
> 
> strangely enough, 
> 
>     "os.system(r'dir Program Files')"
> 
> doesn't work either.  nor does
> 
>     c:\> "dir program files"
> 
> at the command prompt.
> 
> (when you get this far, you should have
> realised how to fix this...  but alright, I'll
> spell it out:
>    
>     c:\> dir "program files"
>     os.system('dir "program files"')
> 
> but in this specific case, you should use
> "os.listdir" or perhaps "glob.glob" instead,
> but that's another story...)
> 
> </F>
> 
> <!-- (the eff-bot guide to) the standard python library:
> http://www.pythonware.com/people/fredrik/librarybook.htm
> (news: just posted an errata for the 'first printing') -->
> 





More information about the Python-list mailing list