Enumerating drives in Python or wxPython

David Bolen db3l at fitlinxx.com
Wed Jul 12 15:07:21 EDT 2000


"Neil Hodgson" <neilh at scintilla.org> writes:

>    So, I'll repeat Richard's code and copy it to your email in the hope that
> telia is better at email than usenet.
> 
> import win32api,string
> 
> drives=win32api.GetLogicalDriveStrings()
> drives=string.splitfields(drives,'\000')
> print drives
> 
>    Looks like it gets one too many elements - the last is empty.

That's due to the definition for GetLogicalDriveStrings() - it returns
a string of NUL-terminated drive names back to back, and the overall
list is terminated with another NUL.  So if you split on the NUL,
you'll always have an empty string at the end.

--
-- David
-- 
/-----------------------------------------------------------------------\
 \               David Bolen            \   E-mail: db3l at fitlinxx.com  /
  |             FitLinxx, Inc.            \  Phone: (203) 708-5192    |
 /  860 Canal Street, Stamford, CT  06902   \  Fax: (203) 316-5150     \
\-----------------------------------------------------------------------/



More information about the Python-list mailing list