Re: File existence check with partial filename

2010-03-15 Thread Steven Howe
What wrong with glob? --- Help on module glob: NAME glob - Filename globbing utility. FILE /usr/lib64/python2.6/glob.py FUNCTIONS glob(pathname) Return a list of paths matching a pathname pattern. The pattern may contain simple shell-style wildca

Re: File existence check with partial filename

2010-03-15 Thread MRAB
Lan Qing wrote: Or use the regular module: import re import os for filename in os.listdir('.'): if re.match("*HV*", filename): # do something with the file The regular expression should be ".*HV.*", although: re.search("HV", filename) would be better and: "HV" in file

Re: File existence check with partial filename

2010-03-15 Thread Lan Qing
Or use the regular module: import re import os for filename in os.listdir('.'): if re.match("*HV*", filename): # do something with the file On Mon, Mar 15, 2010 at 12:24 PM, Alf P. Steinbach wrote: > * Sang-Ho Yun: > > I learned that I can check the existence of a file using >>

Re: File existence check with partial filename

2010-03-14 Thread Gary Herron
Alf P. Steinbach wrote: * Sang-Ho Yun: I learned that I can check the existence of a file using os.path.isfile("filename"). What if I need to check if there is a file that contains "HV" in the filename? What should I do? from __future__ import print_function import os for filen

Re: File existence check with partial filename

2010-03-14 Thread Alf P. Steinbach
* Sang-Ho Yun: I learned that I can check the existence of a file using os.path.isfile("filename"). What if I need to check if there is a file that contains "HV" in the filename? What should I do? from __future__ import print_function import os for filename in os.listdir( "." ):

File existence check with partial filename

2010-03-14 Thread Sang-Ho Yun
I learned that I can check the existence of a file using os.path.isfile("filename"). What if I need to check if there is a file that contains "HV" in the filename? What should I do? Thank you, Sang-Ho -- http://mail.python.org/mailman/listinfo/python-list