Diez B. Roggisch wrote:
SamFeltus schrieb:
When a list initializes, will it always evaluate in order starting at
element 0 and finishing with the last element?

def f1(x):
    return x + 2

def f2(x):
    return x * 2

def f3(x):
    return x * 3

the_list = [f1(7), f2(8), f3(4)]

Yes.

From the fine manual:

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}
expr1 + expr2 * (expr3 - expr4)
expr1(expr2, expr3, *expr4, **expr5)
expr3, expr4 = expr1, expr2

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to