def whereis(program):
 for path in os.environ.get('PATH', '').split(':'):
  if (os.path.exists(os.path.join(path, program)) and (not os.path.isdir(os.path.join(path, program)))):
   return os.path.join(path, program)
 return None

def whereis ( program ) : for path in os . environ . get ( 'PATH' , '' ) . split ( ':' ) : if ( os . path . exists ( os . path . join ( path , program ) ) and ( not os . path . isdir ( os . path . join ( path , program ) ) ) ) : return os . path . join ( path , program ) return None
search path for executable .