5.13 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:

expr1, expr2, expr3, expr4
(expr1, expr2, expr3, expr4)
expr1 + expr2 * (expr3 - expr4)
func(expr1, expr2, *expr3, **expr4)
expr3, expr4 = expr1, expr2

Dictionaries are currently an exception to the rule and they evaluate in the following order:

{expr2: expr1, expr4: expr3}

In Python 2.3, the order will be changed to be consistent with other expressions:

{expr1: expr2, expr3: expr4}

See About this document... for information on suggesting changes.