Enumerating drives in Python or wxPython
David Bolen
db3l at fitlinxx.com
Thu Jul 13 18:27:28 EDT 2000
Alan Miller <ajm at enteract.com> writes:
> import string, os
>
> drivelist = []
>
> for driveletter in string.uppercase:
> if os.path.isdir(driveletter + ":\\"):
> drivelist.append(driveletter)
>
> print drivelist
The only rub with this is that for things like floppies, you can get
errors running isdir() if there is no diskette present.
--
-- 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