Emacs: Open Python Doc 🚀

By Xah Lee. Date: . Last updated: .

here's a convenient command to open the python doc.

(defvar xah-python-doc-path
  nil
  "A list of file full paths to python doc in HTML, used by `xah-open-python-doc'.
Each element is tried to check if it exist. (this is useful if you have multiple machines with different operating systems.)
On Windows Python 3.9, it's a .chm file, not supported by this command.")

(setq xah-python-doc-path
(list
"~/AppData/Local/Programs/Python/Python312/Doc/html/index.html"
))

(defun xah-open-python-doc ()
  "Open python doc file `xah-python-doc-path'.

URL `http://xahlee.info/emacs/emacs/emacs_open_python_doc.html'
Created: 2023-03-18
Version: 2024-11-19"
  (interactive)
  (let ((xpath (seq-some (lambda (x) (if (file-exists-p x) x nil)) xah-python-doc-path)))
    (cond
     ((not xpath) (message "no file exists in paths `xah-python-doc-path' %s" xah-python-doc-path) nil)
     ((string-equal (file-name-extension xpath) "html") (browse-url xpath))
     (t
      (message "file exist at %s but is not HTML suffix." xpath)
      nil))))