<div dir="ltr"><div class="gmail_quote"><div>&gt;&gt; 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">


&gt;     def internalfunc():<br>
&gt;         return cc * myparam<br>
&gt;<br>
&gt; CPython infers that in &#39;internalfunc&#39;, while &#39;myparam&#39; is free, &#39;cc&#39; is<br>
<br>
</div>What exactly do you mean by &quot;infers&quot; ? 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 &#39;symtable&#39; module. With its help, it&#39;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&#39;m misunderstanding something or the term &#39;free&#39; is indeed used for different things in different places. If this is the latter, IMHO it&#39;s an inconsistency, even if a small one. When I read the code I saw  &#39;free&#39; I went to the docs only to read that &#39;free&#39; is something else. This was somewhat confusing.<br>

<br>Eli<br><br> </div><br></div><br></div>