tags:

views:

154

answers:

3

If I use M-x shell and run the interactive Python interpreter, Emacs on Windows does not return any IO.

When I discovered M-x python-shell, I regained hope. However, instead of running the interactive Python shell, I want to run a specific Python script that features an interactive CLI. (See Python's cmd module for details).

Is there a way of launching a Python script in Emacs that is interactive? (stdout, stdin, stderr)

+1  A: 

Hi,

I grabbed one of the cmd examples from here: http://www.doughellmann.com/PyMOTW/cmd/index.html

Seemed like all the input lines in the example had a (Cmd) prompt - not sure if that's always the case.

Edited the python-shell definition in python.el to include "(Cmd) "

(setq comint-prompt-regexp "^>>> \\|^[.][.][.] \\|^(pdb) \\|^\\(Cmd\\) ")

re-evaluated the python-shell region, started the shell and loaded the script using:

>>> execfile("script.py")

Input/output seemed to work... not sure about stderr or if this would work with a more complicated script.

myCubeIsMyCell
+1  A: 

You should look into the other shell modes. TERM-MODE and ANSI-MODE. I believe they can support interactive command line programs.

openist
A: 

While not a direct answer to your question, I've found Emacs to have very poor support for Python. In my own experience all the Python devs I worked with used VI/VIM.

Have you checked out pydev for eclipse? http://pydev.sourceforge.net/

If none of these appeal to you then good luck with Emacs..

Stephen

Desolate Planet