def shutil_which(pgm):
 path = os.getenv('PATH')
 for p in path.split(os.path.pathsep):
  p = os.path.join(p, pgm)
  if (os.path.exists(p) and os.access(p, os.X_OK)):
   return p

def shutil_which ( pgm ) : path = os . getenv ( 'PATH' ) for p in path . split ( os . path . pathsep ) : p = os . path . join ( p , pgm ) if ( os . path . exists ( p ) and os . access ( p , os . X_OK ) ) : return p
python 2 compatibility: backport of shutil .