Enumerating drives in Python or wxPython

Alex Martelli alex at magenta.com
Wed Jul 12 08:07:33 EDT 2000


"someguy" <jdub at nospam.net> wrote in message
news:8kft65$rnc$1 at news2.acs.oakland.edu...
> Drive letters could easily be enumerated using com & following the VB
Script
> examples, only substituting python instead.

I.e., basically, something like:

import win32com.client

def printDriveLetters():
    fso=win32com.client.Dispatch("Scripting.FileSystemObject")
    for drive in fso.Drives:
        print drive.DriveLetter

> Drive letters aren't a cross platform concept.  I know of no native Python
> functions to perform this action.

Agreed!  I prefer relying on objects and methods in the "scripting
runtime" component, rather than on win32api.stuff, for this sort of
tasks -- it's a nice, simple, decently consistent object model.


Alex






More information about the Python-list mailing list