recursive glob
Seo Sanghyeon
unendliche at hanmail.net
Mon Jun 23 02:05:33 EDT 2003
Egor Bolonev wrote:
> yield func work incorrect an I can't fix it - please help me
(snip)
def rec_glob(path,mask):
if path[-1]!='\\':
path=path+'\\'
for i in rec_glob_get_dirs(path):
# This one is the problem!
# rec_glob(path+i,mask)
# Try the following:
for ii in rec_glob(path+i,mask):
yield ii
try:
for i in os.listdir(path):
ii=i
i=path+i
if os.path.isfile(i):
if fnmatch.fnmatch(ii,mask):
yield i
except:pass
Calling the function that contains yield, it returns the generator.
Generator is just yet another object. So your line, "rec_glob(path+i,mask)",
has no effect. It is same as writing "1", or "'string'" alone.
-- Seo Sanghyeon
More information about the Python-list
mailing list