how on earth do i get a drive list?
Peter Hansen
peter at engcorp.com
Thu Jul 26 19:17:52 EDT 2001
"G. Willoughby" wrote:
>
> how on earth do i get a drive list? i've been searching for a command to
> display a tuple or list containing all available drives, but i can't find
> it! is it just me or are the standard python docs quite confusing. oh well
> any ideas out there?
On Windows, with the win32all stuff installed:
>>> import win32api
>>> drives = win32api.GetLogicalDriveStrings()
>>> drives
'a:\\\x00c:\\\x00d:\\\x00e:\\\x00v:\\\x00'
>>> drives.split('\x00')[:-1]
['a:\\', 'c:\\', 'd:\\', 'e:\\', 'v:\\']
This is definitely not cross-platform, and I know nothing about the Windows
API so there are very likely much better ways to do this, but this one's
kind of cute... :)
--
----------------------
Peter Hansen, P.Eng.
peter at engcorp.com
More information about the Python-list
mailing list