Find Disk Usage with shutil

As I move to python as my primary programming language, I am discovering new things about the modules that i have used for many years, one such module is the shutil.

To check free disk space, one can use the following command

  _, _, free = shutil.disk_usage("")

shutil.disk_usage returns the disk usage statistics about a given path

Returned values is a named tuple with attributes ‘total’, ‘used’, ‘free’, which are the amount of total, used and free space in bytes.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s