def filter(names, pat):
 result = []
 pat = os.path.normcase(pat)
 match = _compile_pattern(pat)
 if (os.path is posixpath):
  for name in names:
   if match(name):
    result.append(name)
 else:
  for name in names:
   if match(os.path.normcase(name)):
    result.append(name)
 return result

def filter ( names , pat ) : result = [ ] pat = os . path . normcase ( pat ) match = _compile_pattern ( pat ) if ( os . path is posixpath ) : for name in names : if match ( name ) : result . append ( name ) else : for name in names : if match ( os . path . normcase ( name ) ) : result . append ( name ) return result
filters out unwanted items using the specified function .