How do I restart the IDLE Python Shell in Linux?
Asked Answered
M

3

7

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?

Millenarian answered 18/11, 2011 at 20:38 Comment(0)
F
2

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?

Ferrochromium answered 18/11, 2011 at 20:42 Comment(1)
OK, it does work now. Before, I used from my_module import my_function, which means I did not import the module, only the function. The documentation says the whole module must have been imported previously for reload(my_module) to work. So, I typed import my_module. Thanks a lot!Millenarian
D
2

Restart Shell has a keyboard shortcut of ctrl+F6, you could always try that.

Decagon answered 18/11, 2011 at 20:41 Comment(0)
F
2

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?

Ferrochromium answered 18/11, 2011 at 20:42 Comment(1)
OK, it does work now. Before, I used from my_module import my_function, which means I did not import the module, only the function. The documentation says the whole module must have been imported previously for reload(my_module) to work. So, I typed import my_module. Thanks a lot!Millenarian
D
1

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.

Duvalier answered 11/10, 2012 at 22:33 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.