<div dir="ltr">The execution model section of the Python reference manual defines free variables as follows:<br><br> "If a variable is used in a code block but not defined there, it is a free variable"<br><br>
This makes sense and fits the academic definition. The documentation of the symtable module supports this definition - it says about is_free(): "return True if the symbol is referenced in its block but not assigned to".<br>
<br>However, it appears that in the CPython front-end source code (in particular the parts dealing with the symbol table), a free variables has a somewhat stricter meaning. For example, in this chunk of code:<br><br>def some_func(myparam):<br>
def internalfunc():<br> return cc * myparam<br><br>CPython infers that in 'internalfunc', while 'myparam' is free, 'cc' is global because 'cc' isn't bound in the enclosing scope, although according to the definitions stated above, both should be considered free. The bytecode generated for loading cc and myparam is different, of course.<br>
<br>Is there a (however slight) inconsistency of terms here, or is it my misunderstanding?<br><br>Thanks in advance,<br>Eli<br><br><br><br><br><br></div>