Код: Выделить всё
def f(x):
some processing including api calls and executing some command line subprocesses.
return f(x)
A = [{"a1":a1, "a2":a2 .... },{"b1":b1 ....},...,{"n1:n1...}]
def Z(A):
X = []
for a in A:
x = f(a)
X.append(x)
return X
Z(A)
добавляя операторы печати:
Код: Выделить всё
def f(x):
some processing including api calls and executing some command line subprocesses.
return f(x)
A = [{"a1":a1, "a2":a2 .... },{"b1":b1 ....},...,{"n1:n1...}]
def Z(A):
X = []
for a in A:
print(X)
x = f(a)
print(X)
X.append(x)
print(X)
return X
Z(A)
[]
[]
[f(a)]
однако для следующей итерации я получить
[f(a)]
[f(b)]
[f(b),f(b)]
и третий
[f(b),f(b)]
[f(c),f( в)]
[f(c),f(c),f(c)]
и т. д. и т. д.
Почему копирование Python происходит раньше, чем я скажи это.
Что происходит
Подробнее здесь: https://stackoverflow.com/questions/792 ... ll-them-to
Мобильная версия