Unwrap Python's dir() list into multi line text.
authorOleksandr Gavenko <gavenkoa@gmail.com>
Tue, 26 Jan 2021 00:38:11 +0200
changeset 1707 84c30e639991
parent 1706 26b2fc3886f9
child 1708 e6320b167b77
Unwrap Python's dir() list into multi line text.
.emacs-my
--- a/.emacs-my	Mon Jan 25 10:55:00 2021 +0200
+++ b/.emacs-my	Tue Jan 26 00:38:11 2021 +0200
@@ -3071,15 +3071,21 @@
 (setq python-indent-offset 4)
 
 (defun my-python/describe-at-point (symbol process prefix)
-  "Show full docs for symbol at point."
+  "Show full docs for symbol at point using Python's help() built-in.
+
+With argument 1 uses Python's type() built-in.
+With argument 2 uses Python's repr() built-in.
+With argument 1 uses Python's dir() built-in.
+With argument 1 uses Python's vars() built-in."
   (interactive (list (python-info-current-symbol)
                      (python-shell-get-process)
                      current-prefix-arg))
   (let ( (cmd
           (cond
            ((eq 1 prefix) (concat "type(" symbol ")\n"))
-           ((eq 2 prefix) (concat "vars(" symbol ")\n"))
-           ((eq 3 prefix) (concat "repr(" symbol ")\n"))
+           ((eq 2 prefix) (concat "repr(" symbol ")\n"))
+           ((eq 3 prefix) (concat "print('\\n'.join(dir(" symbol ")))\n"))
+           ((eq 4 prefix) (concat "vars(" symbol ")\n"))
            ((not prefix) (concat "help('" symbol "')\n"))
            (t (concat "dir(" symbol ")\n")))) )
     (switch-to-buffer (get-buffer-create (format "*pydoc: %s*" symbol)))