finding file

su suma.37 at gmail.com
Mon Jun 5 08:32:18 EDT 2006


Hi , I am trying to understand myself with some basic programs in
python, I have written a small script to search for core files in the
current dir. but when i tried to execute, it is searching the core
files in the subdir also. could someone help me on how can i restrict
my code to search the file in the current dir only

import os, os.path
import re
def core_finder(arg, dir, files):
    for file in files:
        path = os.path.join (dir, file)
        if re.search("core.*", path):
           print "found"
           print path


os.path.walk('.', core_finder, 0)




More information about the Python-list mailing list