Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
pythonfree variables中的场景到底是什么。nested functions谁能详细解释它们的用途以及它们与正常变量的区别?
free variables
nested functions
例子:
def outer(outer_param): # `outer` has no free variables outer_var = 2 def inner(inner_param): # `outer_param` and `outer_var` are free variables of `inner` inner_var = outer_param + outer_var + inner_param return inner_var