Search code examples
emacsipythonpython-mode

Execute the expression and print its value in Emacs python mode


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!


Solution

  • Maybe consider a feature request at

    https://bugs.launchpad.net/python-mode