简体   繁体   English

如何在Linux中重新启动IDLE Python Shell?

[英]How do I restart the IDLE Python Shell in Linux?

In IDLE on Windows, on the menu bar, there is a Shell menu. 在Windows上的IDLE中,在菜单栏上有一个Shell菜单。 One of the items on the Shell menu is 'Restart Shell'. Shell菜单上的一个项目是'Restart Shell'。 The Shell menu is not available in IDLE on Linux. Shell菜单在Linux上的IDLE中不可用。

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. 在模块中进行更改并希望在shell中再次运行模块后,Restart Shell命令很有用。

In IDLE on Linux, I have to close IDLE and open it again for the shell to notice the change in the module. 在Linux上的IDLE中,我必须关闭IDLE并再次打开它以使shell注意到模块中的更改。

How can I restart the shell without closing and reopening IDLE as a whole? 如何重新启动shell而不关闭并重新打开IDLE?

If you want the changes in module to be visible, just call something like that (where my_module is your module you updated): 如果您希望模块中的更改可见,只需调用类似的内容( my_module是您更新的模块):

reload(my_module)

See docs on reload() . 请参阅reload()上的文档

Did it help? 它有帮助吗?

IDLE have two modes of operation - with subprocess and without it. IDLE有两种操作模式 - 使用子进程,没有它。 The 'restart shell' option is available only with subprocess. 'restart shell'选项仅适用于子进程。 The default mode is with subprocess, but it can be changed using the argument '-n' when starting IDLE. 默认模式是子进程,但可以在启动IDLE时使用参数'-n'进行更改。

Apparently, the menu item that starts IDLE on Linux does that with the '-n' argument. 显然,在Linux上启动IDLE的菜单项使用'-n'参数执行此操作。 Open IDLE without this flag and your 'restart shell' option will be back. 打开没有此标志的IDLE,您的“重启shell”选项将返回。

重启Shell有一个键盘快捷键ctrl + F6,你总是可以试试。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM