Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the closest thing to SLIME for python ? / What's the best way to use python from EMACS?

I'm trying to write some python, and I'm used to the lispy way of doing things, a REPL in EMACS and the ability to send arbitrary code snippets to the REPL. I like this way of developing code, and python's built-in IDLE seems to do it pretty well. However I do like EMACS as an editor.

What's the best thing analogous to SLIME for Python?


So far:

It seems that the trick is to open a python file, and then to use 'Start Interpreter' from the Python menu, after which you get an Inferior Python buffer. You can then use C-c C-c to load the whole buffer you're editing into the 'REPL', and use normal copy and paste to put snippets into the REPL.

This works as far as it goes. Is there any way to say 'reevaluate the big thing that the cursor is in now and display the answer', or 'reevaluate the thing the cursor is just at the end of and display the answer', like M-C-x and C-x-e in SLIME?

And it all seems to work better if you use the python-mode.el from Bozhidar's answer

like image 318
John Lawrence Aspden Avatar asked Mar 15 '11 18:03

John Lawrence Aspden


People also ask

Is Emacs good for Python?

Emacs for Python Development With elpy. Emacs is ready out of the box to edit Python code. The library file python. el provides python-mode, which enables basic indentation and syntax highlighting support.

How do I run Python code in Emacs?

Once you open your python file in Emacs, you will need to start the python process with: M-x run-python or C-c C-p , which creates an inferior python shell buffer. This buffer will be created by a horizontal split, and the active buffer will be the one containing the python file.


2 Answers

There is ipython.el which you can use for some extended functionality over the vanilla python-mode. Ropemacs provides a few extra completion and refactoring related options that might help you. This is discussed here. However, I don't expect you're going to get anything close to SLIME.

like image 110
Noufal Ibrahim Avatar answered Sep 21 '22 14:09

Noufal Ibrahim


I think the new python.el is a much better idea. It's under active development, it can spawn a python shell and send function definitions, buffers and files to it. It also has better than average re-indent support. It's rumoured that in Emacs 24 it might become the default python mode in Emacs.

like image 35
Bozhidar Batsov Avatar answered Sep 22 '22 14:09

Bozhidar Batsov