code: def which(exe_name):
      
      def is_exe(file_path_name):
          return os.path.isfile(file_path_name) and os.access(file_path_name, os.X_OK)
  
      is_platform_windows = (platform.system() == 'Windows')
  
      fpath, _fname = os.path.split(exe_name)
      if fpath:
          if is_exe(exe_name):
              return exe_name
      else:
          for path in os.environ['PATH'].split(os.pathsep):
              exe_file_path_name = os.path.join(path, exe_name)
              if is_exe(exe_file_path_name):
                  return exe_file_path_name
  
              if is_platform_windows:
                  windows_exe_file_path_name = '%s.exe' % exe_file_path_name
                  if is_exe(windows_exe_file_path_name):
                      return windows_exe_file_path_name
  
                  windows_com_file_path_name = '%s.exe' % exe_file_path_name
                  if is_exe(windows_com_file_path_name):
                      return windows_com_file_path_name
  
      return None
docs: Locate a program file in the user's path.
  
      @param exec_name: name of the executable file.
  
      @return: ``None`` if the executable has not been found in the user's
          path, or the path for the executable file.