Skip to content
8 changes: 4 additions & 4 deletions Doc/library/os.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3665,16 +3665,16 @@ features:

This example displays the number of bytes taken by non-directory files in each
directory under the starting directory, except that it doesn't look under any
CVS subdirectory::
``__pycache__`` subdirectory::

import os
from os.path import join, getsize
for root, dirs, files in os.walk('python/Lib/email'):
for root, dirs, files in os.walk('python/Lib'):
print(root, "consumes", end=" ")
print(sum(getsize(join(root, name)) for name in files), end=" ")
print("bytes in", len(files), "non-directory files")
if 'CVS' in dirs:
dirs.remove('CVS') # don't visit CVS directories
if '__pycache__' in dirs:
dirs.remove('__pycache__') # don't visit __pycache__ directories

In the next example (simple implementation of :func:`shutil.rmtree`),
walking the tree bottom-up is essential, :func:`rmdir` doesn't allow
Expand Down
Loading