<div dir="ltr"><div class="gmail_quote"><div>>> def some_func(myparam): <br></div><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
> def internalfunc():<br>
> return cc * myparam<br>
><br>
> CPython infers that in 'internalfunc', while 'myparam' is free, 'cc' is<br>
<br>
</div>What exactly do you mean by "infers" ? How do you know that it infers<br>
that? How does it matter for your understanding of the code?<br></blockquote><div><br>The easiest way I found to see what CPython thinks is use the 'symtable' module. With its help, it's clear that in the function above, myparam is considered free while cc is considered global. When querying symtable about the symbol myparam, the is_free method returns True while the is_global method returns False, and vice versa for cc.<br>
<br>Of course it can also be seen in the code of symtable.c in function analyze_name, and as Nick showed in his message it also affects the way bytecode is generated for the two symbols.<br><br>My intention in this post was to clarify whether I'm misunderstanding something or the term 'free' is indeed used for different things in different places. If this is the latter, IMHO it's an inconsistency, even if a small one. When I read the code I saw 'free' I went to the docs only to read that 'free' is something else. This was somewhat confusing.<br>
<br>Eli<br><br> </div><br></div><br></div>