Python code, extracting extensions
Question: > **Possible Duplicate:**  
>  [In python, how can I check if a filename ends in '.html' or
> '_files'?](http://stackoverflow.com/questions/10873777/in-python-how-can-i-
> check-if-a-filename-ends-in-html-or-files)
    
    
    import os
    
    path = '/Users/Marjan/Documents/Nothing/Costco'
    
    print path
    
    names = os.listdir(path)
    
    print len(names)
    
    for name in names:
      print name
    

Here is the code I've been using, it lists all the names in this category in
terminal. There are a few filenames in this file (Costco) that don't have
.html and _files. I need to pick them out, the only issue is that it has over
2,500 filenames. Need help on a code that will search through this path and
pick out all the filenames that don't end with .html or _files. Thanks guys


Answer: 
    for name in names:
        if filename.endswith('.html') or filename.endswith('_files'):
            continue
        #do stuff
    

Usually
[`os.path.splitext()`](http://docs.python.org/library/os.path.html#os.path.splitext)
would be more appropriate if you needed the extension of a file, but in this
case `endswith()` is perfectly fine.

