|
|
|
|
|
by Spivak
1000 days ago
|
|
Ignoring the strange nature of this code in the first place the more pythonic way to do it would be from functools import partial
from operators import add
add_n = [partial(add, n)) for n in range(10)]
assert add_n[5](4) == 9
Look ma, no closures. |
|