diff options
author | Georg Brandl <georg@python.org> | 2008-01-05 19:29:45 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2008-01-05 19:29:45 (GMT) |
commit | 6265833d91b53aec0d710d81ec91cee142b0e204 (patch) | |
tree | 1f63195180a8896940ff3aabc9c930790bb0c120 /Doc/reference/simple_stmts.rst | |
parent | 9749e15e2ff9fffd987679cc3914c726af8876b3 (diff) | |
download | cpython-6265833d91b53aec0d710d81ec91cee142b0e204.zip cpython-6265833d91b53aec0d710d81ec91cee142b0e204.tar.gz cpython-6265833d91b53aec0d710d81ec91cee142b0e204.tar.bz2 |
Simplify index entries; fix #1712.
Diffstat (limited to 'Doc/reference/simple_stmts.rst')
-rw-r--r-- | Doc/reference/simple_stmts.rst | 78 |
1 files changed, 34 insertions, 44 deletions
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst index 513543b..0767170 100644 --- a/Doc/reference/simple_stmts.rst +++ b/Doc/reference/simple_stmts.rst @@ -34,7 +34,9 @@ simple statements is: Expression statements ===================== -.. index:: pair: expression; statement +.. index:: + pair: expression; statement + pair: expression; list Expression statements are used (mostly interactively) to compute and write a value, or (usually) to call a procedure (a function that returns no meaningful @@ -45,8 +47,6 @@ expression statement is: .. productionlist:: expression_stmt: `expression_list` -.. index:: pair: expression; list - An expression statement evaluates the expression list (which may be a single expression). @@ -311,13 +311,13 @@ is determined when the interpreter starts. The :keyword:`pass` statement ============================= -.. index:: statement: pass +.. index:: + statement: pass + pair: null; operation .. productionlist:: pass_stmt: "pass" -.. index:: pair: null; operation - :keyword:`pass` is a null operation --- when it is executed, nothing happens. It is useful as a placeholder when a statement is required syntactically, but no code needs to be executed, for example:: @@ -332,15 +332,14 @@ code needs to be executed, for example:: The :keyword:`del` statement ============================ -.. index:: statement: del - -.. productionlist:: - del_stmt: "del" `target_list` - .. index:: + statement: del pair: deletion; target triple: deletion; target; list +.. productionlist:: + del_stmt: "del" `target_list` + Deletion is recursively defined very similar to the way assignment is defined. Rather that spelling it out in full details, here are some hints. @@ -399,8 +398,6 @@ functional to write an empty string to standard output for this reason.) .. index:: single: output pair: writing; values - -.. index:: pair: trailing; comma pair: newline; suppression @@ -434,15 +431,14 @@ then ``sys.stdout`` is used as the file for output. The :keyword:`return` statement =============================== -.. index:: statement: return - -.. productionlist:: - return_stmt: "return" [`expression_list`] - .. index:: + statement: return pair: function; definition pair: class; definition +.. productionlist:: + return_stmt: "return" [`expression_list`] + :keyword:`return` may only occur syntactically nested in a function definition, not within a nested class definition. @@ -468,17 +464,16 @@ raised. The :keyword:`yield` statement ============================== -.. index:: statement: yield - -.. productionlist:: - yield_stmt: `yield_expression` - .. index:: + statement: yield single: generator; function single: generator; iterator single: function; generator exception: StopIteration +.. productionlist:: + yield_stmt: `yield_expression` + The :keyword:`yield` statement is only used when defining a generator function, and is only used in the body of the generator function. Using a :keyword:`yield` statement in a function definition is sufficient to cause that definition to @@ -528,15 +523,14 @@ clauses to execute. The :keyword:`raise` statement ============================== -.. index:: statement: raise - -.. productionlist:: - raise_stmt: "raise" [`expression` ["," `expression` ["," `expression`]]] - .. index:: + statement: raise single: exception pair: raising; exception +.. productionlist:: + raise_stmt: "raise" [`expression` ["," `expression` ["," `expression`]]] + If no expressions are present, :keyword:`raise` re-raises the last exception that was active in the current scope. If no exception is active in the current scope, a :exc:`TypeError` exception is raised indicating that this is an error @@ -578,16 +572,15 @@ and information about handling exceptions is in section :ref:`try`. The :keyword:`break` statement ============================== -.. index:: statement: break - -.. productionlist:: - break_stmt: "break" - .. index:: + statement: break statement: for statement: while pair: loop; statement +.. productionlist:: + break_stmt: "break" + :keyword:`break` may only occur syntactically nested in a :keyword:`for` or :keyword:`while` loop, but not nested in a function or class definition within that loop. @@ -614,17 +607,16 @@ really leaving the loop. The :keyword:`continue` statement ================================= -.. index:: statement: continue - -.. productionlist:: - continue_stmt: "continue" - .. index:: + statement: continue statement: for statement: while pair: loop; statement keyword: finally +.. productionlist:: + continue_stmt: "continue" + :keyword:`continue` may only occur syntactically nested in a :keyword:`for` or :keyword:`while` loop, but not nested in a function or class definition or :keyword:`finally` statement within that loop. [#]_ It continues with the next @@ -739,8 +731,6 @@ raise a :exc:`SyntaxError`. .. index:: keyword: from statement: from - -.. index:: triple: hierarchical; module; names single: packages single: __init__.py @@ -840,13 +830,13 @@ after the script is executed. The :keyword:`global` statement =============================== -.. index:: statement: global +.. index:: + statement: global + triple: global; name; binding .. productionlist:: global_stmt: "global" `identifier` ("," `identifier`)* -.. index:: triple: global; name; binding - The :keyword:`global` statement is a declaration which holds for the entire current code block. It means that the listed identifiers are to be interpreted as globals. It would be impossible to assign to a global variable without @@ -908,7 +898,7 @@ variables. If two expressions are given, they are used for the global and local variables, respectively. If provided, *locals* can be any mapping object. .. versionchanged:: 2.4 - formerly *locals* was required to be a dictionary. + Formerly, *locals* was required to be a dictionary. .. index:: single: __builtins__ |