[docs] [issue34115] code.InteractiveConsole.interact() closes stdin

Terry J. Reedy report at bugs.python.org
Sat Jul 21 01:16:21 EDT 2018


Terry J. Reedy <tjreedy at udel.edu> added the comment:

There is an important difference between a program saying 'I am done executing' and a user saying 'I am done with the interactive session'.  This is especially true in an IDE where 'session' can include many editing and shell sessions.

'Stop executing'  happens when execution reaches the end of the file, which causes EOFError upon a read attempt.  It can also be done gracefully before the end of input with sys.exit(), which raises SystemExit.

In Interactive Python, 'leave session' can be done with SystemExit or the EOF control signal, which appears to raise EOFError.  This suggests that quit() and exit(), which were added because newbies did not know the proper way to exit, should raise EOFError rather than SystemExit.  The fact that 'quit' displays 'Use quit() or Ctrl-Z plus Return to exit' (EOF on Windows) suggests the same.  But I need to experiment (another day).

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34115>
_______________________________________


More information about the docs mailing list