2

Possible Duplicate:
Is there a way to list all the available drive letters in python?

What's the way to retrieve currently mounted drive list in Windows incl. Thumb drives, and mapped networks.

i currently do

    drives=[]
    for c in string.lowercase:
        if os.path.isdir(c+':'):
            drives.append(c+':')

which looks ugly, but is completely KISS proof :)

Community
  • 1
  • 1
Berry Tsakala
  • 15,313
  • 12
  • 57
  • 80
  • Duplicate: http://stackoverflow.com/questions/827371/is-there-a-way-to-list-all-the-available-drive-letters-in-python – S.Lott Jun 05 '09 at 17:02

1 Answers1

3
win32api.GetLogicalDriveStrings().split("\x00")
Sanjaya R
  • 6,246
  • 2
  • 17
  • 19
  • Here is a full working example based on Sanjaya's answer: `import win32api def does_drive_exist(letter): return (letter in win32api.GetLogicalDriveStrings().split("\x00")) print does_drive_exist("P:\\")` – Jason Willett Mar 24 '13 at 18:51