Why does IDLE not finish running the program automatically?

Asked

Viewed 456 times

6

I think it’s more of a curiosity. Unlike other IDE’s, IDLE keeps the program "open" even after the end of its run, while in other IDE’s I need to put something like 'input()' at the end so the program won’t be terminated until I enter some value.

Would someone like to explain to me why IDLE has this behavior?

3 answers

3


This is due to the fact that IDLE uses Python’s own console to run its programs, line by line. Therefore, when the execution of your program ends, IDLE does not exit Python automatically, because IDLE works with Python interactive mode, that is, it executes all commands sent by a text input (terminal or stdin) and process them as they are typed.

1

In fact, IDLE does end the execution of programs.

The problem is that it has two basic components: the Python console (known as "interactive mode") and the editor. Programs loaded into the editor can be executed normally with the command "Run > Run module" or the shortcut "F5".

The outputs will be displayed on the console, but the program itself will be run and terminated as elsewhere, saved in case of errors.

Already in the console, as already said, you enter a sequence of commands, one after the other, which are executed at each input.

0

The advantage of this is that the program’s global variables and functions remain accessible. Having a look at them may be useful, especially if the program ended but didn’t work as expected.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.