def my_walk(top_dir, ignore):
    for dirpath, dirnames, filenames in os.walk(top_dir):
        dirnames[:] = [dn for dn in dirnames if os.path.join(dirpath, dn)
             not in ignore]
yield dirpath, dirnames, filenames
Уокер Python, который может игнорировать каталоги