windows directory

Richard Lewis richardlewis at fastmail.co.uk
Tue Jun 14 04:31:42 EDT 2005


On Tue, 14 Jun 2005 15:32:02 +0800, "Austin" <austin at maxtronic.com.tw>
said:
> I would like to write a program which creates the folders in specific
> directory.
> For example, I want to create folder in Program Files. How do I know
> which
> is in C:\ or D:\
> Is there any function to get the active path?
> 

You can find the current working directory with
os.getcwd()

If you want to know where a particular directory is (on a Windows
'drive') you could use:

for drive_label in ["C", "D"]:
    if "Program Files" in os.listdir(drive_label + ":/"): return
    drive_label

Or something similar.

Cheers,
Richard



More information about the Python-list mailing list