[Python-checkins] peps: Moved order of evaluation into the Specification section, since it's guaranteed.

eric.smith python-checkins at python.org
Fri Aug 28 18:21:48 CEST 2015


https://hg.python.org/peps/rev/220f74d3b747
changeset:   6002:220f74d3b747
user:        Eric V. Smith <eric at trueblade.com>
date:        Fri Aug 28 12:21:04 2015 -0400
summary:
  Moved order of evaluation into the Specification section, since it's guaranteed.

files:
  pep-0498.txt |  38 +++++++++++++++++++-------------------
  1 files changed, 19 insertions(+), 19 deletions(-)


diff --git a/pep-0498.txt b/pep-0498.txt
--- a/pep-0498.txt
+++ b/pep-0498.txt
@@ -360,6 +360,25 @@
 For ease of readability, leading and trailing whitespace in
 expressions is ignored.
 
+Evaluation order of expressions
+-------------------------------
+
+The expressions in an f-string are evaluated in left-to-right
+order. This is detectable only if the expressions have side effects::
+
+  >>> def fn(l, incr):
+  ...    result = l[0]
+  ...    l[0] += incr
+  ...    return result
+  ...
+  >>> lst = [0]
+  >>> f'{fn(lst,2)} {fn(lst,3)}'
+  '0 2'
+  >>> f'{fn(lst,2)} {fn(lst,3)}'
+  '5 7'
+  >>> lst
+  [10]
+
 Discussion
 ==========
 
@@ -602,25 +621,6 @@
 
   f'{x:.{width}}'
 
-Evaluation order of expressions
--------------------------------
-
-The expressions in an f-string are evaluated in left-to-right
-order. This is detectable only if the expressions have side effects::
-
-  >>> def fn(l, incr):
-  ...    result = l[0]
-  ...    l[0] += incr
-  ...    return result
-  ...
-  >>> lst = [0]
-  >>> f'{fn(lst,2)} {fn(lst,3)}'
-  '0 2'
-  >>> f'{fn(lst,2)} {fn(lst,3)}'
-  '5 7'
-  >>> lst
-  [10]
-
 Expressions used multiple times
 -------------------------------
 

-- 
Repository URL: https://hg.python.org/peps


More information about the Python-checkins mailing list