Answer the question
In order to leave comments, you need to log in
[closures] Why doesn't the outer function argument need to be specified as nonlocal in the inner function?
Hey!
There is a closure:
def outer(x):
count = 555
num = 666
def inner():
nonlocal count, num
return x
return inner
muller = outer(777)
print(muller())
print(muller.__closure__[0].cell_contents, muller.__closure__[1].cell_contents, muller.__closure__[2].cell_contents)
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question