Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions Doc/using/cmdline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -302,16 +302,22 @@ Miscellaneous options

.. option:: -i

Enter interactive mode after execution.
Enter interactive mode after execution, or force interactive mode even when
:data:`sys.stdin` does not appear to be a terminal.
Comment on lines +305 to +306
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would probably rewrite it as it is worded in python --help.

forces a prompt even if stdin does not appear to be a terminal

Saying "interactive" is not quite correct, "prompt" better describes it.


Using the :option:`-i` option will enter interactive mode in any of the following circumstances\:

* When a script is passed as first argument
* When the :option:`-c` option is used
* When the :option:`-m` option is used

Interactive mode will start even when :data:`sys.stdin` does not appear to be a terminal. The
:envvar:`PYTHONSTARTUP` file is not read.
In these "execute then interact" cases, Python runs the script or command
first and does not read the :envvar:`PYTHONSTARTUP` file before entering
interactive mode.

When :option:`-i` is used only to force interactive mode despite redirected
standard input (for example, ``python -i < /dev/null``), the interpreter
enters interactive mode directly and reads :envvar:`PYTHONSTARTUP` as usual.

This can be useful to inspect global variables or a stack trace when a script
raises an exception. See also :envvar:`PYTHONINSPECT`.
Expand Down
Loading