code: def _is_executable_file(path):
      
      # follow symlinks,
      fpath = os.path.realpath(path)
  
      if not os.path.isfile(fpath):
          # non-files (directories, fifo, etc.)
          return False
  
      return os.access(fpath, os.X_OK)
docs: Checks that path is an executable regular file, or a symlink towards one.
      This is roughly ``os.path isfile(path) and os.access(path, os.X_OK)``.
  
      This function was forked from pexpect originally:
  
      Copyright (c) 2013-2014, Pexpect development team
      Copyright (c) 2012, Noah Spurrier <noah@noah.org>
  
      PERMISSION TO USE, COPY, MODIFY, AND/OR DISTRIBUTE THIS SOFTWARE FOR ANY
      PURPOSE WITH OR WITHOUT FEE IS HEREBY GRANTED, PROVIDED THAT THE ABOVE
      COPYRIGHT NOTICE AND THIS PERMISSION NOTICE APPEAR IN ALL COPIES.
      THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
      WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
      MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
      ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
      WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
      ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
      OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.