Extended mind
Notes and Thoughts
The keeping of a second brain
Home
Closures in Python capture variables not values
def random_function(s): print(s) letters = [] for s in ["a", "b", "c"]: letters.append((s, lambda : random_function(s))) for url, f in letters: f() This prints c c c The reason …
Python dictionaries are insertion-ordered from 3.7+
They are insertion-ordered in CPython implementation of Python 3.6 as an implementation detail. Guido announced on the mailing list that it is officially part of the language spec in Python 3.7 …
© Lingyi