diff options
author | Georg Brandl <georg@python.org> | 2010-03-21 19:29:04 (GMT) |
---|---|---|
committer | Georg Brandl <georg@python.org> | 2010-03-21 19:29:04 (GMT) |
commit | 5a7eca17498f3e7ed54c0d569bfd4f19bc81fe9f (patch) | |
tree | d66b48add092c9847fd99441cd81824734ecd55e /Doc/reference | |
parent | d131c10732d53343ae2c53830e3b2c67d9060aca (diff) | |
download | cpython-5a7eca17498f3e7ed54c0d569bfd4f19bc81fe9f.zip cpython-5a7eca17498f3e7ed54c0d569bfd4f19bc81fe9f.tar.gz cpython-5a7eca17498f3e7ed54c0d569bfd4f19bc81fe9f.tar.bz2 |
Merged revisions 77593,77702-77703,77858,77887,78113-78115,78117,78245,78385-78386,78496,78760,78771-78773,78802 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r77593 | georg.brandl | 2010-01-18 00:33:53 +0100 (Mo, 18 Jan 2010) | 1 line
Fix internal reference.
........
r77702 | georg.brandl | 2010-01-23 09:43:31 +0100 (Sa, 23 Jan 2010) | 1 line
#7762: fix refcount annotation of PyUnicode_Tailmatch().
........
r77703 | georg.brandl | 2010-01-23 09:47:54 +0100 (Sa, 23 Jan 2010) | 1 line
#7725: fix referencing issue.
........
r77858 | georg.brandl | 2010-01-30 18:57:48 +0100 (Sa, 30 Jan 2010) | 1 line
#7802: fix invalid example (heh).
........
r77887 | georg.brandl | 2010-01-31 19:51:49 +0100 (So, 31 Jan 2010) | 5 lines
Fix-up ftplib documentation:
move exception descriptions to toplevel, not inside a class
remove attribution in "versionadded"
spell and grammar check docstring of FTP_TLS
........
r78113 | georg.brandl | 2010-02-08 23:37:20 +0100 (Mo, 08 Feb 2010) | 1 line
Fix missing string formatting argument.
........
r78114 | georg.brandl | 2010-02-08 23:37:52 +0100 (Mo, 08 Feb 2010) | 1 line
Fix undefined local.
........
r78115 | georg.brandl | 2010-02-08 23:40:51 +0100 (Mo, 08 Feb 2010) | 1 line
Fix missing string formatting placeholder.
........
r78117 | georg.brandl | 2010-02-08 23:48:37 +0100 (Mo, 08 Feb 2010) | 1 line
Convert test failure from output-producing to self.fail().
........
r78245 | georg.brandl | 2010-02-19 20:36:08 +0100 (Fr, 19 Feb 2010) | 1 line
#7967: PyXML is no more.
........
r78385 | georg.brandl | 2010-02-23 22:33:17 +0100 (Di, 23 Feb 2010) | 1 line
#8000: fix deprecated directive. What a shame to lose that glorious issue number to such a minor bug :)
........
r78386 | georg.brandl | 2010-02-23 22:48:57 +0100 (Di, 23 Feb 2010) | 1 line
#6544: fix refleak in kqueue, occurring in certain error conditions.
........
r78496 | georg.brandl | 2010-02-27 15:58:08 +0100 (Sa, 27 Feb 2010) | 1 line
Link to http://www.python.org/dev/workflow/ from bugs page.
........
r78760 | georg.brandl | 2010-03-07 16:23:59 +0100 (So, 07 Mär 2010) | 1 line
#5341: more built-in vs builtin fixes.
........
r78771 | georg.brandl | 2010-03-07 21:58:31 +0100 (So, 07 Mär 2010) | 1 line
#8085: The function is called PyObject_NewVar, not PyObject_VarNew.
........
r78772 | georg.brandl | 2010-03-07 22:12:28 +0100 (So, 07 Mär 2010) | 1 line
#8039: document conditional expressions better, giving them their own section.
........
r78773 | georg.brandl | 2010-03-07 22:32:06 +0100 (So, 07 Mär 2010) | 1 line
#8044: document Py_{Enter,Leave}RecursiveCall functions.
........
r78802 | georg.brandl | 2010-03-08 17:28:40 +0100 (Mo, 08 Mär 2010) | 1 line
Fix typo.
........
Diffstat (limited to 'Doc/reference')
-rw-r--r-- | Doc/reference/executionmodel.rst | 4 | ||||
-rw-r--r-- | Doc/reference/expressions.rst | 37 |
2 files changed, 28 insertions, 13 deletions
diff --git a/Doc/reference/executionmodel.rst b/Doc/reference/executionmodel.rst index 9f6170d..4e38536 100644 --- a/Doc/reference/executionmodel.rst +++ b/Doc/reference/executionmodel.rst @@ -119,7 +119,7 @@ searched. The global statement must precede all uses of the name. .. index:: pair: restricted; execution -The built-in namespace associated with the execution of a code block is actually +The builtins namespace associated with the execution of a code block is actually found by looking up the name ``__builtins__`` in its global namespace; this should be a dictionary or a module (in the latter case the module's dictionary is used). By default, when in the :mod:`__main__` module, ``__builtins__`` is @@ -131,7 +131,7 @@ weak form of restricted execution. .. impl-detail:: Users should not touch ``__builtins__``; it is strictly an implementation - detail. Users wanting to override values in the built-in namespace should + detail. Users wanting to override values in the builtins namespace should :keyword:`import` the :mod:`__builtin__` (no 's') module and modify its attributes appropriately. diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst index e060670..c03113c 100644 --- a/Doc/reference/expressions.rst +++ b/Doc/reference/expressions.rst @@ -185,6 +185,7 @@ brackets: list_comprehension: `expression` `list_for` list_for: "for" `target_list` "in" `old_expression_list` [`list_iter`] old_expression_list: `old_expression` [("," `old_expression`)+ [","]] + old_expression: `or_test` | `old_lambda_form` list_iter: `list_for` | `list_if` list_if: "if" `old_expression` [`list_iter`] @@ -1136,12 +1137,7 @@ Boolean operations pair: Conditional; expression pair: Boolean; operation -Boolean operations have the lowest priority of all Python operations: - .. productionlist:: - expression: `conditional_expression` | `lambda_form` - old_expression: `or_test` | `old_lambda_form` - conditional_expression: `or_test` ["if" `or_test` "else" `expression`] or_test: `and_test` | `or_test` "or" `and_test` and_test: `not_test` | `and_test` "and" `not_test` not_test: `comparison` | "not" `not_test` @@ -1158,12 +1154,6 @@ special method for a way to change this.) The operator :keyword:`not` yields ``True`` if its argument is false, ``False`` otherwise. -The expression ``x if C else y`` first evaluates *C* (*not* *x*); if *C* is -true, *x* is evaluated and its value is returned; otherwise, *y* is evaluated -and its value is returned. - -.. versionadded:: 2.5 - .. index:: operator: and The expression ``x and y`` first evaluates *x*; if *x* is false, its value is @@ -1183,6 +1173,29 @@ not bother to return a value of the same type as its argument, so e.g., ``not 'foo'`` yields ``False``, not ``''``.) +Conditional Expressions +======================= + +.. versionadded:: 2.5 + +.. index:: + pair: conditional; expression + pair: ternary; operator + +.. productionlist:: + conditional_expression: `or_test` ["if" `or_test` "else" `expression`] + expression: `conditional_expression` | `lambda_form` + +Conditional expressions (sometimes called a "ternary operator") have the lowest +priority of all Python operations. + +The expression ``x if C else y`` first evaluates the condition, *C* (*not* *x*); +if *C* is true, *x* is evaluated and its value is returned; otherwise, *y* is +evaluated and its value is returned. + +See :pep:`308` for more details about conditional expressions. + + .. _lambdas: .. _lambda: @@ -1276,6 +1289,8 @@ groups from right to left). +===============================================+=====================================+ | :keyword:`lambda` | Lambda expression | +-----------------------------------------------+-------------------------------------+ +| :keyword:`if` -- :keyword:`else` | Conditional expression | ++-----------------------------------------------+-------------------------------------+ | :keyword:`or` | Boolean OR | +-----------------------------------------------+-------------------------------------+ | :keyword:`and` | Boolean AND | |