Original Translation
953
The interpreter may also be invoked in interactive mode; in this case, it does not read and execute a complete program but reads and executes one statement (possibly compound) at a time. The initial environment is identical to that of a complete program; each statement is executed in the namespace of :mod:`__main__`.
954
Under Unix, a complete program can be passed to the interpreter in three forms: with the :option:`-c` *string* command line option, as a file passed as the first command line argument, or as standard input. If the file or standard input is a tty device, the interpreter enters interactive mode; otherwise, it executes the file as a complete program.
955
File input
956
All input read from non-interactive files has the same form:
957
This syntax is used in the following situations:
958
when parsing a complete Python program (from a file or from a string);
959
when parsing a module;
960
when parsing a string passed to the :func:`exec` function;
961
Interactive input
962
Input in interactive mode is parsed using the following grammar:
963
Note that a (top-level) compound statement must be followed by a blank line in interactive mode; this is needed to help the parser detect the end of the input.
964
Expression input
965
There are two forms of expression input. Both ignore leading whitespace. The string argument to :func:`eval` must have the following form:
966
Note: to read 'raw' input line without interpretation, you can use the the :meth:`readline` method of file objects, including ``sys.stdin``.