os.walk help

afilip--usenet at freenet.de afilip--usenet at freenet.de
Mon Nov 24 06:16:31 EST 2003


> This script is not recursive... in order to make it recursive, I have to 

> call it several times (my kludge... hey, it works). I thought os.walk's 
> sole purpose was to recursively walk a directory structure, no? Also,it 
> generates the below error during the os.renames section, but the odd 
> thing is that it actually renames the files before saying it can't find 
> them. Any ideas are welcomed. If I'm doing something *really* wrong 
> here, just let me know.

Try iterating from bottom to top.

See "help(os.walk)":
walk(top, topdown=True, onerror=None)

    ...
 
    If optional arg 'topdown' is true or not specified, the triple for a
    directory is generated before the triples for any of its 
subdirectories
    (directories are generated top down).  If topdown is false, the triple
    for a directory is generated after the triples for all of its
    subdirectories (directories are generated bottom up).

    ...





More information about the Python-list mailing list