summaryrefslogtreecommitdiffstats
path: root/Doc/ref/ref5.tex
diff options
context:
space:
mode:
authorThomas Wouters <thomas@python.org>2006-02-27 00:24:13 (GMT)
committerThomas Wouters <thomas@python.org>2006-02-27 00:24:13 (GMT)
commitdca3b9c797f6dd4b08d590fa2aa1031e22ab598e (patch)
treed2b7aa53793110100965906b1266296d08bd4ec1 /Doc/ref/ref5.tex
parentd3a5f53a27be821cfdff869fd8ad93a060497e8c (diff)
downloadcpython-dca3b9c797f6dd4b08d590fa2aa1031e22ab598e.zip
cpython-dca3b9c797f6dd4b08d590fa2aa1031e22ab598e.tar.gz
cpython-dca3b9c797f6dd4b08d590fa2aa1031e22ab598e.tar.bz2
PEP 308 implementation, including minor refdocs and some testcases. It
breaks the parser module, because it adds the if/else construct as well as two new grammar rules for backward compatibility. If no one else fixes parsermodule, I guess I'll go ahead and fix it later this week. The TeX code was checked with texcheck.py, but not rendered. There is actually a slight incompatibility: >>> (x for x in lambda:0) Traceback (most recent call last): File "<stdin>", line 1, in <module> TypeError: iteration over non-sequence changes into >>> (x for x in lambda: 0) File "<stdin>", line 1 (x for x in lambda: 0) ^ SyntaxError: invalid syntax Since there's no way the former version can be useful, it's probably a bugfix ;)
Diffstat (limited to 'Doc/ref/ref5.tex')
-rw-r--r--Doc/ref/ref5.tex11
1 files changed, 8 insertions, 3 deletions
diff --git a/Doc/ref/ref5.tex b/Doc/ref/ref5.tex
index 462548f..65a3cff 100644
--- a/Doc/ref/ref5.tex
+++ b/Doc/ref/ref5.tex
@@ -155,8 +155,7 @@ square brackets:
\begin{productionlist}
\production{test}
- {\token{and_test} ( "or" \token{and_test} )*
- | \token{lambda_form}}
+ {\token{or_test} | \token{lambda_form}}
\production{testlist}
{\token{test} ( "," \token{test} )* [ "," ]}
\production{list_display}
@@ -1017,7 +1016,8 @@ Boolean operations have the lowest priority of all Python operations:
\begin{productionlist}
\production{expression}
- {\token{or_test} | \token{lambda_form}}
+ {\token{or_test} [\token{if} \token{or_test} \token{else}
+ \token{test}] | \token{lambda_form}}
\production{or_test}
{\token{and_test} | \token{or_test} "or" \token{and_test}}
\production{and_test}
@@ -1036,6 +1036,11 @@ The operator \keyword{not} yields \code{True} if its argument is false,
\code{False} otherwise.
\opindex{not}
+The expression \code{\var{x} if \var{C} else \var{y}} first evaluates
+\var{C} (\emph{not} \var{x}); if \var{C} is true, \var{x} is evaluated and
+its value is returned; otherwise, \var{y} is evaluated and its value is
+returned.
+
The expression \code{\var{x} and \var{y}} first evaluates \var{x}; if
\var{x} is false, its value is returned; otherwise, \var{y} is
evaluated and the resulting value is returned.