wasm-demo/demo/ermis-f/python_m/cur/0282

41 lines
1.3 KiB
Plaintext

From: msrisney at my-dejanews.com (msrisney at my-dejanews.com)
Date: Sat, 24 Apr 1999 04:30:56 GMT
Subject: wrapped around the axle on regexpressions and file searching
Message-ID: <7frhe0$8g1$1@nnrp1.dejanews.com>
Content-Length: 1070
X-UID: 282
Hey Pythoniers!
I'm attemtping to locate log files on my drive(s), and do some comparison.
here's a simplified snippet where I'm getting bottlenecked.
>>>import os,re
>>>regexp = re.compile('.log')
>>>def find_log_files(arg, directory, names):
...for name in os.listdir(directory):
if regexp.search(name):
print directory + "\\" + name
>>>os.path.walk('D:\\',find_log_files,None)
here are my questions: 1. this prints out not only files with the file
extensions ".log" but also any file name that has "log" in it's name. how
would I rewrite to avoid??
2. is there a better, faster way of doing this??, my end goal is to open the
files and compare time sequences to one another.
3. Is ther any way to determine the number of drives on a system, obviuosly I
am hardcoding the top level drive letter "D:\", is there any way to search the
entire system much like win32's find file search??
TIA
-----------== Posted via Deja News, The Discussion Network ==----------
http://www.dejanews.com/ Search, Read, Discuss, or Start Your Own