Skip to main content
Bumped by Community user
Bumped by Community user
edited tags
Link
Drew
  • 79.1k
  • 10
  • 123
  • 257
Bumped by Community user
Source Link
atevm
  • 958
  • 7
  • 17

Function to restart python console

I wrote a very simple function to properly restart ipython console with elpy when evaluating the buffer or region:

(defun my-restart-python-console ()
  "Restart python console before evaluate buffer or region to avoid various uncanny conflicts, like not reloding modules even when they are changed"
  (interactive)
  (kill-process "Python")
  (kill-buffer "*Python*")
  (elpy-shell-send-region-or-buffer))

Itt works but always ask confirmation, because "*Python*" has a running process, however I kill the process before killing the buffer.

The fun part: If I evaluate the function body line by line it works...