Mailing List Archive

python/dist/src/Doc/ref ref5.tex,1.53.4.10,1.53.4.11
Update of /cvsroot/python/python/dist/src/Doc/ref
In directory sc8-pr-cvs1:/tmp/cvs-serv31926

Modified Files:
Tag: release22-maint
ref5.tex
Log Message:
Backport documentation of left-to-right evaluation order.
Highlight the difference for dictionaries and provide Py2.2.3
users which advanced notice that the evaluation order will
change for Py2.3.


Index: ref5.tex
===================================================================
RCS file: /cvsroot/python/python/dist/src/Doc/ref/ref5.tex,v
retrieving revision 1.53.4.10
retrieving revision 1.53.4.11
diff -C2 -d -r1.53.4.10 -r1.53.4.11
*** ref5.tex 13 Nov 2002 15:33:13 -0000 1.53.4.10
--- ref5.tex 16 Dec 2002 23:19:19 -0000 1.53.4.11
***************
*** 1022,1025 ****
--- 1022,1056 ----
\indexii{trailing}{comma}

+ \section{Evaluation order\label{evalorder}}
+ \indexii{evaluation}{order}
+
+ Python evaluates expressions from left to right. Notice that while
+ evaluating an assignment, the right-hand side is evaluated before
+ the left-hand side.
+
+ In the following lines, expressions will be evaluated in the
+ arithmetic order of their suffixes:
+
+ \begin{verbatim}
+ expr1, expr2, expr3, expr4
+ (expr1, expr2, expr3, expr4)
+ expr1 + expr2 * (expr3 - expr4)
+ func(expr1, expr2, *expr3, **expr4)
+ expr3, expr4 = expr1, expr2
+ \end{verbatim}
+
+ Dictionaries are currently an exception to the rule and they evaluate
+ in the following order:
+
+ \begin{verbatim}
+ {expr2: expr1, expr4: expr3}
+ \end{verbatim}
+
+ In Python 2.3, the order will be changed to be consistent with
+ other expressions:
+
+ \begin{verbatim}
+ {expr1: expr2, expr3: expr4}
+ \end{verbatim}

\section{Summary\label{summary}}