How do I restart the IDLE Python Shell in Linux?

In IDLE on Windows, on the menu bar, there is a Shell menu. One of the items on the Shell menu is 'Restart Shell'. The Shell menu is not available in IDLE on Linux.

The Restart Shell command is useful after you have made a change in a module and want to run the module again in the shell.

In IDLE on Linux, I have to close IDLE and open it again for the shell to notice the change in the module.

How can I restart the shell without closing and reopening IDLE as a whole?


If you want the changes in module to be visible, just call something like that (where my_module is your module you updated):

reload(my_module)

See docs on reload() .

Did it help?


重新启动外壳有一个ctrl + F6键盘快捷键,你可以随时尝试。


IDLE have two modes of operation - with subprocess and without it. The 'restart shell' option is available only with subprocess. The default mode is with subprocess, but it can be changed using the argument '-n' when starting IDLE.

Apparently, the menu item that starts IDLE on Linux does that with the '-n' argument. Open IDLE without this flag and your 'restart shell' option will be back.

链接地址: http://www.djcxy.com/p/56266.html

上一篇: 服务器无法识别来自Android手机的Cookie

下一篇: 我如何在Linux中重新启动IDLE Python Shell?