Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I would like to have emacs work as a python ide for me. I can't seem to find how to compile from within emacs. I'm using python2.7 but when I do M-x python-mode it seems to compile using python2.7. Is there some command which I could bind to some key so that I can quickly run my code and see the output?

share|improve this question
add comment

1 Answer 1

up vote 5 down vote accepted

Short, unhelpful answer: press C-c C-c.

You can get help on the current mode(s) in use by typing C-h m in Emacs. With a little bit of reading through the various commands supported and a couple of mouse clicks, I found this: in an Emacs buffer holding Python source, pressing C-c C-c (that's CtrlC CtrlC) sends the source to the Python interpreter.

The ‘inferior’ (nothing to do with quality) Python interpreter runs in a buffer named *Python*. You can press C-x 2 to split the window, then C-x o (that's the letter oh) to move to the bottom window, then with C-X b *Python*Enter, select the *Python* buffer. After that, go back to the source window (C-x o) and use C-c C-c whenever you want to run your Python program. This is what it looks like:

enter image description here

You can obviously do all this with a mouse if you don't like keyboard commands. And if you go through the documentation for python-mode, you'll find Emacs commands to send individual functions, classes etc. to the interpreter. Try M-x python-sendTabTab for a list.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.