finding file

K.S.Sreeram sreeram at tachyontech.net
Mon Jun 5 14:45:21 CEST 2006


su wrote:
> 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)

Here's a simpler solution:

import glob
filenames = glob.glob( 'core*' )

In case you want the full path...

import os
filepaths = [os.path.join(os.getcwd(),f) for f in filenames]

Regards
Sreeram

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 260 bytes
Desc: OpenPGP digital signature
URL: <http://mail.python.org/pipermail/python-list/attachments/20060605/cda78b3b/attachment.sig>


More information about the Python-list mailing list