If I use M-x shell and run the interactive Python interpreter, Emacs on Windows d开发者_Python百科oes 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)
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.
You should look into the other shell modes. TERM-MODE and ANSI-MODE. I believe they can support interactive command line programs.
You can run python in interactive mode by typing python.exe -i Alternatively, you can download ipython and just run ipython.exe
精彩评论