Python 1.5 Reference Manual
The syntax for a complete Python program is that for file input, described in the next section.
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 name space of __main__.
Under UNIX , a complete program can be passed to the interpreter in three forms: with the -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.
file_input: (NEWLINE | statement)*This syntax is used in the following situations:
interactive_input: [stmt_list] NEWLINE | compound_stmt NEWLINENote 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.
eval_input: expression_list NEWLINE*The input line read by input() must have the following form:
input_input: expression_list NEWLINENote: to read 'raw' input line without interpretation, you can use the built-in function raw_input() or the readline() method of file objects.
Generated with Harlequin WebMaker