def which_files(file, mode=(F_OK | X_OK), path=None, pathext=None):
 (filepath, file) = split(file)
 if filepath:
  path = (filepath,)
 elif (path is None):
  path = defpath
 elif isinstance(path, str):
  path = path.split(pathsep)
 if (pathext is None):
  pathext = defpathext
 elif isinstance(pathext, str):
  pathext = pathext.split(pathsep)
 if (not ('' in pathext)):
  pathext.insert(0, '')
 for dir in path:
  basepath = join(dir, file)
  for ext in pathext:
   fullpath = (basepath + ext)
   if (exists(fullpath) and access(fullpath, mode)):
    (yield fullpath)

def which_files ( file , mode = ( F_OK | X_OK ) , path = None , pathext = None ) : ( filepath , file ) = split ( file ) if filepath : path = ( filepath , ) elif ( path is None ) : path = defpath elif isinstance ( path , str ) : path = path . split ( pathsep ) if ( pathext is None ) : pathext = defpathext elif isinstance ( pathext , str ) : pathext = pathext . split ( pathsep ) if ( not ( '' in pathext ) ) : pathext . insert ( 0 , '' ) for dir in path : basepath = join ( dir , file ) for ext in pathext : fullpath = ( basepath + ext ) if ( exists ( fullpath ) and access ( fullpath , mode ) ) : ( yield fullpath )
locate a file in a path supplied as a part of the file name .