Skip to content

Commit a51db30

Browse files
committed
Doc: clarify -i interaction with PYTHONSTARTUP
1 parent d716e3b commit a51db30

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

Doc/using/cmdline.rst

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -302,16 +302,22 @@ Miscellaneous options
302302

303303
.. option:: -i
304304

305-
Enter interactive mode after execution.
305+
Enter interactive mode after execution, or force interactive mode even when
306+
:data:`sys.stdin` does not appear to be a terminal.
306307

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

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

313-
Interactive mode will start even when :data:`sys.stdin` does not appear to be a terminal. The
314-
:envvar:`PYTHONSTARTUP` file is not read.
314+
In these "execute then interact" cases, Python runs the script or command
315+
first and does not read the :envvar:`PYTHONSTARTUP` file before entering
316+
interactive mode.
317+
318+
When :option:`-i` is used only to force interactive mode despite redirected
319+
standard input (for example, ``python -i < /dev/null``), the interpreter
320+
enters interactive mode directly and reads :envvar:`PYTHONSTARTUP` as usual.
315321

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

0 commit comments

Comments
 (0)