Newbie: List file system roots

Tim Golden mail at timgolden.me.uk
Fri Aug 24 03:55:01 EDT 2007


Einar W. Høst wrote:
> Hi,
> 
> How would you list the file system roots in Python? That is, I'm looking
> for a way to list all connected drives (C:, D: etc) on a Windows box, or
> all /root, /tmp etc on a *nix box. In Java, there's a built-in API
> function to do this, File.listRoots(), but I couldn't find any
> equivalents in the Python libraries.

Couple of options for Windows (probably more as well):

http://timgolden.me.uk/python/win32_how_do_i/find-drive-types.html
http://timgolden.me.uk/python/wmi_cookbook.html#find-drive-types

TJG




More information about the Python-list mailing list