def function()
num = 1
num += 1
return num
Is num a bound variable or a free variable?
P.S. This code is written in python. There's no former code ahead of this.
def function()
num = 1
num += 1
return num
Is num a bound variable or a free variable?
P.S. This code is written in python. There's no former code ahead of this.
From python doc : If a name is bound in a block, it is a local variable of that block, unless declared as nonlocal. If a name is bound at the module level, it is a global variable. (The variables of the module code block are local and global.) If a variable is used in a code block but not defined there, it is a free variable.
Here num
is defined in function
and as such is bound to it.
You can look to this other post from SO to have an example of free variable