A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from http://mail.python.org/pipermail/python-list/2001-April/081612.html below:

drives in a file chooser

drives in a file chooserKen Seehof kens at sightreader.com
Mon Apr 30 15:43:00 EDT 2001
Well, there's always brute force...

>>> import os, string
>>> def GetDrives():
...  drives = []
...  for a in string.lowercase:
...   if os.path.exists('%s:/'%a):
...    drives.append('%s:'%a)
...  return drives
...
>>> GetDrives()
['a:', 'c:', 'd:', 'e:', 'i:', 'x:']

----------------------------------------------------
Copyright (c) 2001 by Ken Seehof
This document may not be distributed, copied,
duplicated, or replicated, or duplicated in any
form without express permission by Ken Seehof.
Permission is hereby granted.
kseehof at neuralintegrator.com
----------------------------------------------------

----- Original Message -----
From: "Matt Setzer" <dontspamsetzer at nwlink.com>
Newsgroups: comp.lang.python
To: <python-list at python.org>
Sent: Sunday, April 29, 2001 10:21 PM
Subject: Re: drives in a file chooser


>
>     I don't think there's a way to do it from the os module, but if you've
> got the win32 extensions installed this should do it :
>
> from win32file import GetLogicalDrives
>
> def GetDrives() :
>     "Returns a list of valid drives on this system, in order"
>     drives = []
>     driveMask = GetLogicalDrives()
>     for i in range( 0, 31 ) :
>         if driveMask & ( 1 << i ) :
>             drives.append( chr( ord( 'a' ) + i ) )
>
>     return drives
>
> Matt Setzer
>
> "Volucris" <volucris at hotmail.com> wrote in message
> news:3aecd342$0$39601$6e49188b at news.goldengate.net...
> > Is there a way to get a list of the drives available (on win32: c:, a:,
> b:,
> > d:, etc.)? Ultimately, I want to make a file chooser in a Tkinter app.
> > Desperatly I tried
> >
> >     os.listdir(os.path.abspath('c:\\..'))
> >
> > but that does nothing useful. Otherwise, I could just confine my users
to
> a
> > single drive and say it's a security feature.
> >
> > greg
> >
> >
>
>
> --
> http://mail.python.org/mailman/listinfo/python-list
>



More information about the Python-list mailing list

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4