Hi Python gurus:
Is os.popen("find") faster or slower than os.path.walk to find file pattern in
the
directory tree? I thought os.path.walk would be faster than unix find, but
that doesn't
seem to be the case?
What is the fastest way in python to search for a file with a given pattern in
a directory
tree?
Here's the code using os.path.walk:
def find_src_mk_file(walk_lst_result, dirname, fnames):
x = len(dirname)
if (dirname[x-4:x] == "/src"):
result = glob.glob(os.path.join(dirname, "src.mk"))
if result:
walk_lst_result.append(result[0])
def is_makefile_outofdate():
<code>
walk_lst_result = []
os.path.walk( component_dir, find_src_mk_file, walk_lst_result )
# check each src.mk and remove from lst
for sub_file_src_mk in walk_lst_result:
<code>
Anything wrong with this code? Please advise.
Thanks.
Angela
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor