calculate system disk space

Heiko Wundram modelnine at
Sat Dec 10 00:57:11 CET 2005

PyPK wrote:
> I am looking for unix.the recipe is windows specific!!

Parse the output of du/df? :-) I guess that would be simplest... ;-)

Otherwise, use some combination of os.walk() and os.stat(), whereby you
_don't_ use the stat.st_size field to get the file size (on disk) but
rather use stat.st_blocks*stat.st_blksize to get it, as you might come
across so called sparse files which are bigger than their on-disk

For explanations, see:
(entries for stat() and walk())

--- Heiko.

More information about the Python-list mailing list