newbie : prune os.walk

Diez B. Roggisch deetsNOSPAM at web.de
Thu Mar 10 14:06:58 CET 2005


Untestet:

def foo(base, depth=2):
    for root, dirs, files in os.walk(base, True):
         if len(root.split(os.sep)) < depth:
              yield  root, dirs, files

for  root, dirs, files in foo("/tmp"):
     print root, dirs, files

-- 
Regards,

Diez B. Roggisch



More information about the Python-list mailing list