Welcome, guest | Sign In | My Account | Store | Cart
from __future__ import generators

import os

def dirwalk(dir):
    "walk a directory tree, using a generator"
    for f in os.listdir(dir):
        fullpath = os.path.join(dir,f)
        if os.path.isdir(fullpath) and not os.path.islink(fullpath):
            for x in dirwalk(fullpath):  # recurse into subdir
                yield x
        else:
            yield fullpath

History

  • revision 2 (22 years ago)
  • previous revisions are not available