Reputation: 29
One thing always confuses me, which is the counterintuitive dynamic / early binding of Python, especially when I have a for
loop. I heard that Cython has some C language-style semantics, so I tried the following code, but I found that it is still dynamically / early bound
import cython
fns: list = []
i: cython.int
for i in range(100):
fns.append(lambda: i)
print(fns[0]())
print(fns[1]())
output was
99
99
Can you achieve early-binding through Cython?
Upvotes: 0
Views: 71