So, briefly on the topic of lexical scope, what does the following print?
def f():
funcs = []
for i in range(5):
def g():
print i
funcs.append(g)
return funcs
funcs = f()
for func in funcs:
func()
So, briefly on the topic of lexical scope, what does the following print?
def f():
funcs = []
for i in range(5):
def g():
print i
funcs.append(g)
return funcs
funcs = f()
for func in funcs:
func()
4 comments: