You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The two solutions in "What You Should Do Instead" are certainly correct, while there's another solution in that special case, one can simply change
return [lambda x : i * x for i in range(5)]
to
return (lambda x : i * x for i in range(5))
in other words, one can create a generator, rather than a list, to postpone the time when cell contents be evaluated. Actually, a more essential test code could be
for multiplier in create_multipliers():
print multiplier.__closure__[0].cell_contents
FYI.
The text was updated successfully, but these errors were encountered:
The two solutions in "What You Should Do Instead" are certainly correct, while there's another solution in that special case, one can simply change
to
in other words, one can create a generator, rather than a list, to postpone the time when cell contents be evaluated. Actually, a more essential test code could be
FYI.
The text was updated successfully, but these errors were encountered: