Or use the regular module:<div><br></div><div>import re</div><div>import os</div><div><br></div><div>for filename in os.listdir('.'):</div><div>    if re.match("*HV*", filename):</div><div>          # do something with the file<br>
<div><br><div class="gmail_quote">On Mon, Mar 15, 2010 at 12:24 PM, Alf P. Steinbach <span dir="ltr"><<a href="mailto:alfps@start.no">alfps@start.no</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
* Sang-Ho Yun:<div class="im"><br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I learned that I can check the existence of a file using<br>
os.path.isfile("filename").<br>
<br>
What if I need to check if there is a file that contains "HV" in the<br>
filename?  What should I do?<br>
</blockquote>
<br></div>
<code><br>
    from __future__ import print_function<br>
    import os</blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">
    for filename in os.listdir( "." ):<br>
        if "HV" in filename.upper():<br>
            print( filename )<br>
</code><br>
<br>
<br>
Cheers & hth.,<br><font color="#888888">
<br>
- Alf</font><div><div></div><div class="h5"><br>
-- <br>
<a href="http://mail.python.org/mailman/listinfo/python-list" target="_blank">http://mail.python.org/mailman/listinfo/python-list</a><br>
</div></div></blockquote></div><br></div></div>