Space left on device

Jean-Paul Calderone exarkun at divmod.com
Mon Jan 16 18:06:32 CET 2006


On 16 Jan 2006 07:52:46 -0800, sir_alex <chimaera29 at libero.it> wrote:
>Is there any function to see how much space is left on a device (such
>as a usb key)? I'm trying to fill in an mp3 reader in a little script,
>and this information could be very useful! Thanks!

If you are on a platform with statvfs(2):

    >>> import os
    >>> s = os.statvfs('/')
    >>> s.f_bavail * s.f_bsize
    59866619904L
    >>> 

Jean-Paul



More information about the Python-list mailing list