queston with glob!!

Tsang, Edward1 e_tsang at trillium.com
Wed Apr 18 18:22:27 EDT 2001


Thanks for your pointer, but after reading the doc. I do not undertstand
what it means ..
def func1():
    import os.path, glob
        
    os.path.walk(currentDir,self.buildFileList,fileList)
        
    fileList = glob.glob(currentDir+os.sep+'*')
    return fileList

def func2():
    listDir = os.listdir('.')
    
    fileList = []
    fileList = self.buildFileList(listDir,fileList)

Then I should expect fileList containing all the files with the full path
names ...
But I have got the following error:
  
File "/sd/ps/alexma/proj/ntharn/lib/python1.5/lib-tk/Tkinter.py", line 764,
in __call__
  File "/la02/qa/etsang1/ts/9005016/modules/gui/msggen.py", line 246, in
openfile
    fileList = self.buildFileList(listDir,fileList)
  File "/la02/qa/etsang1/ts/9005016/modules/gui/msggen.py", line 233, in
buildFileList
    os.path.walk(currentDir,self.buildFileList,fileList)
  File "/sd/ps/alexma/pyprefix/lib/python1.5/posixpath.py", line 262, in
walk
TypeError: string, list

I think I do not undertstand the doc, especially confusing what the funciton
visit is and what arguments to pass to it ...

Can you give me some help??

-----Original Message-----
From: Sean 'Shaleh' Perry [mailto:shaleh at valinux.com]
Sent: Wednesday, April 18, 2001 2:58 PM
To: EdwardT
Cc: python-list at python.org
Subject: RE: queston with glob!!


> 
> There files inside these directories which I want ot search and store
> recursively from the current diretory down deep to the lowest level of
> subdirectory.
> I use glob.glob(currentDir+os.sep+'*')
> But this can only get me the subdirectory not the files down. If I want
down
> one more level, then I need to write this glob.glob(currentDir + os.sep +
> os.sep +'*')
> which is not a good approach as it is too rigid.
> 
> How can I modify the code to search down to the deepest level?
> 

look at the docs for os.path, specifically walk().





More information about the Python-list mailing list