os.path.walk arg
Matt Gerrans
mgerrans at mindspring.com
Thu Mar 20 23:12:39 EST 2003
"Afanasiy" wrote:
> I don't completely understand that, but I just do...
>
> os.path.walk(self.content,self.processcontent,None)
Does it work? If so, what does the rest of your code look like? This is
what I mean (brief as possible, not my usual coding style):
import os
from pprint import pprint
class Pathinator(object):
def walker(self,directory,files):
self.dirlist.append(directory)
def goGood(self,path):
self.dirlist = []
os.path.walk( path, Pathinator.walker, self )
def goBad(self,path):
self.dirlist = []
os.path.walk( path, self.walker, None ) # Is this what you mean?
p = Pathinator()
p.goGood(r'c:\temp')
print 'From goGood:'
pprint( p.dirlist ) # Shows the list.
print 'From goBad:'
p.goBad(r'c:\temp') # Throws an exception (got 4 args, expected 3)
pprint( p.dirlist )
More information about the Python-list
mailing list