[Tutor] Looking for something similar to du...

Marc Tompkins marc.tompkins at gmail.com
Tue May 6 02:57:38 CEST 2008


On Mon, May 5, 2008 at 5:21 PM, Alan Gauld <alan.gauld at btinternet.com>
wrote:

> Probably but I'm not totally clear what you are looking for.
> Can you explain what you mean by the diffrence between the size
> used versus the size of the image? Surely the size of the image
> is the space it uses? Or are you expanding compressed files?
>

Disk space is allocated in large units (in DOS/Windows they're called
"clusters", *nixes call them "blocks").  A one-byte file still uses an
entire cluster, whose size depends on the size of the disk and the number of
chunks it can be divided into.  So just knowing the size of the file is not
quite enough information if you need to know how much room is left on the
disk...

If you use Windows, you can see this very easily - right-clicking on a JPEG
file and selecting Properties, I get:
Size:             35.1 KB (35,997 bytes)
Size on disk: 48.0 KB (49,152 bytes)

>From the os.stat() docs:

> On some Unix systems (such as Linux), the following attributes may also be
> available: st_blocks (number of blocks allocated for file), st_blksize(filesystem blocksize),
> st_rdev (type of device if an inode device). st_flags (user defined flags
> for file).
>
So apparently os.stat() can get this info from *nix, but not Windows...
maybe behind the scenes, it runs du?
-- 
www.fsrtechnologies.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20080505/0e9d212b/attachment.htm>


More information about the Tutor mailing list