[Python-ideas] Suggestion: Add shutil.get_dir_size

Cameron Simpson cs at zip.com.au
Wed May 3 03:01:12 EDT 2017

On 03May2017 09:13, Ram Rachum <ram at rachum.com> wrote:
>Calling `du` is possible but I prefer to avoid these kinds of solutions.
>(OS-specific, parsing text output from a third-party program.)

Your choice, and fair enough.

However I'd point out that "du" is available on all UNIX systems (includes 
MacOS) and UNIXlike systems (Linux in its many forms), and has the advantage 
that it embodies all the platform specific knowledge you need as alluded to in 
another reply; hard links, block counts things-not-plain-files and so forth.

Of course, I speak here with some hypocracy because I'm the kind of person 
who'd write his own for things like this sometimes also. Starting with Python's 
os.walk function would get you off the ground.

If you end up with something clean and usable by others, publish it to PyPI.

Cameron Simpson <cs at zip.com.au>

More information about the Python-ideas mailing list