I'm using Emacs python-mode and ipython as my IDE to write the python code. Python-mode provides a nice function "py-execute-line" to run one line code, and I've bound it to key "F7".
So for the following code:
cell = "Human" # Move the cursor to this line and run it by pressing F7
print cell # Move the cursor to this line and run it by pressing F7
I can get the output printed in the ipython buffer.
In [80]:
In [81]: Human
I'm wondering whether there's more direct way to check the value of "cell" without the print command. Something like move the cursor to the variable, press some key, and then the value is printed in the ipython output buffer.
cell = "Human" # Move the cursor to this line and run it by pressing F7
cell = "Human" # Move the cursor to "cell" and print its value by pressing ?? key or function
I have tried function (py-execute-expression-ipython), but there is no output printed ...
Thanks in advance!
Without highlighting, I use:
(defun python-eval-expression ()
(interactive)
(let ((py-command (read-string "Command: ")))
(save-excursion
(setq elpy-shell-echo-output t)
(setq elpy-shell-echo-input t)
(elpy-shell--with-maybe-echo (python-shell-send-string py-command)))))
Should be easy to adapt to choose the current selection if exists (using
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With