[Tutor] Using os.path.walk

rhys tucker rhystucker@yahoo.com
Mon, 6 Aug 2001 04:48:51 -0700 (PDT)

I'm trying to use os.path.walk.

#/usr/bin/env python 
import os, shelve
db = shelve.open("shelveTestDB") 
startdir = os.curdir
arg = 1  # How should I deal with this unused
paramater? def diraction(arg, dirname, names):
    count = 0
    files = names
    for fl in files:
        if os.path.isfile(fl):
            count = count + 1

db[fl] = count os.path.walk(startdir, diraction, arg)

For me, the names paramater changes with subsequent
calls to diraction, but files does not. It also
appears that 
"for fl in files" is run only 3 times in total (with
the same files list).



Do You Yahoo!?
Make international calls for as low as $.04/minute with Yahoo! Messenger