summaryrefslogtreecommitdiffstats
path: root/Doc/reference
diff options
context:
space:
mode:
Diffstat (limited to 'Doc/reference')
-rw-r--r--Doc/reference/index.rst2
-rw-r--r--Doc/reference/simple_stmts.rst83
2 files changed, 43 insertions, 42 deletions
diff --git a/Doc/reference/index.rst b/Doc/reference/index.rst
index 18bf053..a179d21 100644
--- a/Doc/reference/index.rst
+++ b/Doc/reference/index.rst
@@ -17,7 +17,7 @@ write a Python extension module, and the :ref:`c-api-index` describes the
interfaces available to C/C++ programmers in detail.
.. toctree::
- :maxdepth: 2
+ :maxdepth: 3
introduction.rst
lexical_analysis.rst
diff --git a/Doc/reference/simple_stmts.rst b/Doc/reference/simple_stmts.rst
index b586871..5693f0d 100644
--- a/Doc/reference/simple_stmts.rst
+++ b/Doc/reference/simple_stmts.rst
@@ -62,47 +62,6 @@ using the built-in :func:`repr` function and the resulting string is written to
standard output on a line by itself (except if the result is ``None``, so that
procedure calls do not cause any output.)
-
-.. _assert:
-
-Assert statements
-=================
-
-.. index::
- statement: assert
- pair: debugging; assertions
- single: __debug__
- exception: AssertionError
-
-Assert statements are a convenient way to insert debugging assertions into a
-program:
-
-.. productionlist::
- assert_stmt: "assert" `expression` ["," `expression`]
-
-The simple form, ``assert expression``, is equivalent to ::
-
- if __debug__:
- if not expression: raise AssertionError
-
-The extended form, ``assert expression1, expression2``, is equivalent to ::
-
- if __debug__:
- if not expression1: raise AssertionError(expression2)
-
-These equivalences assume that :data:`__debug__` and :exc:`AssertionError` refer
-to the built-in variables with those names. In the current implementation, the
-built-in variable :data:`__debug__` is ``True`` under normal circumstances,
-``False`` when optimization is requested (command line option ``-O``). The
-current code generator emits no code for an assert statement when optimization
-is requested at compile time. Note that it is unnecessary to include the source
-code for the expression that failed in the error message; it will be displayed
-as part of the stack trace.
-
-Assignments to :data:`__debug__` are illegal. The value for the built-in
-variable is determined when the interpreter starts.
-
-
.. _assignment:
Assignment statements
@@ -308,6 +267,48 @@ instance variable. For example::
a.x += 1 # writes a.x as 4 leaving A.x as 3
+.. _assert:
+
+The :keyword:`assert` statement
+===============================
+
+.. index::
+ statement: assert
+ pair: debugging; assertions
+
+Assert statements are a convenient way to insert debugging assertions into a
+program:
+
+.. productionlist::
+ assert_stmt: "assert" `expression` ["," `expression`]
+
+The simple form, ``assert expression``, is equivalent to ::
+
+ if __debug__:
+ if not expression: raise AssertionError
+
+The extended form, ``assert expression1, expression2``, is equivalent to ::
+
+ if __debug__:
+ if not expression1: raise AssertionError, expression2
+
+.. index::
+ single: __debug__
+ exception: AssertionError
+
+These equivalences assume that ``__debug__`` and :exc:`AssertionError` refer to
+the built-in variables with those names. In the current implementation, the
+built-in variable ``__debug__`` is ``True`` under normal circumstances,
+``False`` when optimization is requested (command line option -O). The current
+code generator emits no code for an assert statement when optimization is
+requested at compile time. Note that it is unnecessary to include the source
+code for the expression that failed in the error message; it will be displayed
+as part of the stack trace.
+
+Assignments to ``__debug__`` are illegal. The value for the built-in variable
+is determined when the interpreter starts.
+
+
.. _pass:
The :keyword:`pass` statement