using os.stat to determine stat.st_blocks on OS that supports it?

emile at emile at
Tue May 9 01:52:36 EDT 2000

This returns the bytes used, not the disk size.  For example, on my
win95 box 
files grow in block size increments of 4096 bytes.  On the RH6 box, the
size is 1024.  The actual disk file size will be at least the next
higher block 
size increment.  If the file size follows some sort of high water mark,
a file of 10 bytes could use any number of blocks.

There are certainly ways of determining block size for a given file
system, but
none that I could think of that didn't shell out one way or another.

Emile van Sebille
emile at

>>> rec = 80000*' '
>>> open(r'c:\temp.tst','w+b').write(rec)
>>> os.stat(r'c:\temp.tst')
(33206, 0, 2, 1, 0, 0, 80000, 957769200, 957821668, 957821667)
>>> os.path.getsize(r'c:\temp.tst')

aaron sterling <aarons at> wrote in message
news:<3917BAB6.6E277DE at>...
> have you tried os.path.getsize()
> -- 

More information about the Python-list mailing list