[Python-Dev] Function in os module for available disk space, why not?

Fredrik Lundh fredrik@pythonware.com
Mon, 19 Mar 2001 14:04:59 +0100


dinu wrote:
> Well, this is the usual "If you need it, do it yourself!"
> answer, that bites the one who dares to speak up for all
> those hundreds who don't... isn't it?

fwiw, Python already supports this for real Unix platforms:

>>> os.statvfs("/")    
(8192, 512, 524288, 365788, 348336, 600556, 598516, 598516, 0, 255)

here, the root disk holds 524288x512 bytes, with 348336x512
bytes free for the current user, and 365788x512 bytes available
for root.

(the statvfs module contains indices for accessing this "struct")

Implementing a small subset of statvfs for Windows wouldn't
be that hard (possibly returning None for fields that don't make
sense, or are too hard to figure out).

(and with win32all, I'm sure it can be done without any C code).

Cheers /F