[issue28853] locals() and free variables

2016-12-03 Thread Marco Buttu
Marco Buttu added the comment: I close it because the meaning of "free variable" is not clear. We are discussing about it in issue 26683. -- resolution: -> postponed status: open -> closed ___ Python tracker

[issue28853] locals() and free variables

2016-12-03 Thread Julien Palard
Julien Palard added the comment: Should this issue be closed so? -- ___ Python tracker ___ ___

[issue28853] locals() and free variables

2016-12-03 Thread Marco Buttu
Marco Buttu added the comment: Sorry, in the last example, for the code object ``x`` is not free both in ``foo()`` and ``moo()``, but this does not affect the conclusion. -- ___ Python tracker

[issue28853] locals() and free variables

2016-12-03 Thread Marco Buttu
Marco Buttu added the comment: Martin, I removed the class blocks by accident. In any case, I reject the patch by myself, because to me the definition of "free variable" is not clear. The documentation [1] says: "If a variable is used in a code block but not defined there, it is a free

[issue28853] locals() and free variables

2016-12-02 Thread Terry J. Reedy
Changes by Terry J. Reedy : -- nosy: +terry.reedy ___ Python tracker ___ ___

[issue28853] locals() and free variables

2016-12-02 Thread Martin Panter
Martin Panter added the comment: Marco, your patch removes the description for class blocks. Is that your intent, or just an accident? See r53954. My understanding is “function block” is there to distinguish these three modes: def foo(): # Function block print(locals()) class Bar:

[issue28853] locals() and free variables

2016-12-02 Thread Xavier de Gaye
Xavier de Gaye added the comment: FWIW the definition of free variables can be found in the Language Reference at section 4.2.1. "Binding of names" [1]. The list of the free variables of a user defined function can be accessed through the __closure__ function attribute, a tuple. The function

[issue28853] locals() and free variables

2016-12-02 Thread R. David Murray
R. David Murray added the comment: To answer the parenthetical question (I haven't looked at the doc issue itself), we don't doctest the examples because most of them were written before sphinx grew a doctest extension, so a lot of them don't pass for reasons that have nothing to do with code

[issue28853] locals() and free variables

2016-12-02 Thread Marco Buttu
Marco Buttu added the comment: Yes, it is the same. "Free variables belonging to the enclosing local namespaces" are "non-global free variables". In order for the reader to better contextualize the sentence, I think it is worth keeping the code example in the patch. --

[issue28853] locals() and free variables

2016-12-02 Thread Julien Palard
Julien Palard added the comment: Hi, thanks for reporting, Variables are defined in python docs¹ by: > If a name is bound in a block, it is a local variable of that block, unless > declared as nonlocal or global. If a name is bound at the module level, it is > a global variable. (The

[issue28853] locals() and free variables

2016-12-02 Thread Marco Buttu
Marco Buttu added the comment: In addition, also if here "function blocks" means nested function, the sentence "Free variables are returned by locals() when it is called in function blocks" I think is wrong. It is true only in case of free variables belonging to the local enclosing scope. For

[issue28853] locals() and free variables

2016-12-01 Thread Marco Buttu
New submission from Marco Buttu: The locals() documentation [1] says that "Free variables are returned by locals() when it is called in function blocks". A free variable inside a function has a global scope, and in fact it is not returned by locals():: >>> x = 33 >>> def foo(): ...