Skip to content

Instantly share code, notes, and snippets.

@python-consulting
Created July 27, 2016 11:59
Show Gist options
  • Save python-consulting/d5b6a658e746c814df74ac6431606757 to your computer and use it in GitHub Desktop.
Save python-consulting/d5b6a658e746c814df74ac6431606757 to your computer and use it in GitHub Desktop.
os walk tree
import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
print root, "consumes",
print sum(getsize(join(root, name)) for name in files),
print "bytes in", len(files), "non-directory files"
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment