Working with curses in IPython. How can I improve this?

ぐ巨炮叔叔 提交于 2019-12-03 14:40:39

It turns out that we can now just use IPython in a fairly natural manner for interactively working with curses.

From one terminal simply type:

ipython kernel

This will print a line something like:

[IPKernelApp] To connect another client to this kernel, use:
[IPKernelApp] --existing kernel-14321.json

From another terminal/window type:

ipython console --existing kernel-14321.json

... and you'll be in a seemingly perfectly normal IPython session. The only difference will be that you're actually accessing the "remote" IPython kernel session in the other window. From there you'll be able to use curses functions, see changes in the other window, type inputs thereto, use [Tab]-completion, and so on.

Note that [Ctrl]-[D] will offer to exit the IPython console (client) while quit() will close the IPython kernel (remote window --- server).

But, overall this model is cleaner and easier then what I described in my question last year. I don't know if it's the newer version of IPython (0.13.1) or if was simple ignorance that made my previous attempts somewhat clunkier.

I have found an answer to the tab completion, you can acquire the IPython shell object using get_ipython(), and then call init_completer() on it:

get_ipython().init_completer()

It should be possible to acquire the kernel and shut it down, to quit the terminal application., too but crawling around the documentation has so far not uncovered how.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!