8. Komponen tingkat atas
************************

*Interpreter* Python dapat memperoleh masukan dari sejumlah sumber:
dari skrip yang diteruskan sebagai masukan standar atau sebagai
argumen program, diketikkan secara interaktif, dari berkas sumber
modul, dll. Bab ini memberikan sintaks yang digunakan dalam kasus-
kasus tersebut.


8.1. Program Python lengkap
===========================

While a language specification need not prescribe how the language
interpreter is invoked, it is useful to have a notion of a complete
Python program.  A complete Python program is executed in a minimally
initialized environment: all built-in and standard modules are
available, but none have been initialized, except for "sys" (various
system services), "__builtin__" (built-in functions, exceptions and
"None") and "__main__".  The latter is used to provide the local and
global namespace for execution of the complete program.

Sintaksis untuk program Python lengkap adalah untuk masukan berkas,
dijelaskan pada bagian selanjutnya.

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 "__main__".

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.


8.2. Masukan dari Berkas
========================

Semua input yang dibaca dari berkas non-interaktif memiliki bentuk
yang sama:

   file_input ::= (NEWLINE | statement)*

Sintaks ini digunakan dalam situasi berikut:

* saat mengurai program Python lengkap (dari berkas atau dari
  string);

* ketika mengurai sebuah modul;

* when parsing a string passed to the "exec" statement;


8.3. Masukan interaktif
=======================

Input dalam mode interaktif diuraikan menggunakan tata bahasa berikut:

   interactive_input ::= [stmt_list] NEWLINE | compound_stmt NEWLINE

Perhatikan bahwa pernyataan gabungan (tingkat atas) harus diikuti oleh
baris kosong dalam mode interaktif; ini diperlukan untuk membantu
parser mendeteksi akhir masukan.


8.4. Masukan ekspresi
=====================

There are two forms of expression input.  Both ignore leading
whitespace. The string argument to "eval()" must have the following
form:

   eval_input ::= expression_list NEWLINE*

The input line read by "input()" must have the following form:

   input_input ::= expression_list NEWLINE

Note: to read 'raw' input line without interpretation, you can use the
built-in function "raw_input()" or the "readline()" method of file
objects.
