Error in documentation of "6.14 Evaluation order"

https://docs.python.org/3.8/reference/expressions.html#evaluation-order the example states "expressions will be evaluated in the arithmetic order of their suffixes" but for the line: `expr1(expr2, expr3, *expr4, **expr5)` this is not true - or at least misleading. this error goes way back until version 2.5: https://documentation.help/Python-2.5/evalorder.html were the outer 'expr1' was labeled 'func' the actual order should be (if I'm not totally mistaken): expr5(expr1, expr2, *expr3, **expr4) the simple program: def expr(*args, **kwargs): print(*args, *(zip(kwargs.keys(), kwargs.values()))) expr(expr("1"), expr("2"), expr("3"), d=expr("4")) returns: 1 2 3 4 None None None ('d', None)

Hi Oliver, Le 4/20/21 à 11:21 PM, Oliver Biwer a écrit :
https://docs.python.org/3.8/reference/expressions.html#evaluation-order <https://docs.python.org/3.8/reference/expressions.html#evaluation-order>
the example states "expressions will be evaluated in the arithmetic order of their suffixes" but for the line: `expr1(expr2, expr3, *expr4, **expr5)` this is not true - or at least misleading.
I think a better way to demonstrate it is:
def expr(x): ... print(x) ... if x == 1: return print ... if x == 4: return [] ... if x == 5: return {} ... expr(1)(expr(2), expr(3), *expr(4), **expr(5)) 1 2 3 4 5 None None
Here we see that expr(1) is evaluated **before** expr(2). If you have an idea how to clarify this in the documentation, feel free to tell. -- [Julien Palard](https://mdk.fr)
participants (2)
-
Julien Palard
-
Oliver Biwer