[issue6925] Doc for locals and vars

2009-09-19 Thread Terry J. Reedy
Terry J. Reedy added the comment: My point was and is that global variables *are* free variables by the definition I learned and that I quoted and that in the absence of an 'official' and consistent definition for the purpose of the manual, (linked to from its usages) people can and probably wil

[issue6925] Doc for locals and vars

2009-09-19 Thread Georg Brandl
Georg Brandl added the comment: > I disagree with calling only nonlocal variables but not module variables > 'free'. As I quoted from Wikipedia, that restrictive definition is not > agree on by all at all. But it is the definition that Python uses, at least in the code. I agree that the usage

[issue6925] Doc for locals and vars

2009-09-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: I disagree with calling only nonlocal variables but not module variables 'free'. As I quoted from Wikipedia, that restrictive definition is not agree on by all at all. From The Free On-line Dictionary of Computing, "1. A variable referred to in a function, whic

[issue6925] Doc for locals and vars

2009-09-18 Thread Georg Brandl
Georg Brandl added the comment: Should be fixed now in r74930. I kept "free variables" because this is the correct term, while "nonlocals" clashes with the "nonlocal" statement in 3.x. -- resolution: -> fixed status: open -> closed ___ Python track

[issue6925] Doc for locals and vars

2009-09-18 Thread Terry J. Reedy
Terry J. Reedy added the comment: OK. Same is true of vars() also. So I suggest that current locals() entry be changed to "Update and return a dictionary representing the current local symbol table. In function blocks, this includes nonlocal names. Note The contents of this dictionary should n

[issue6925] Doc for locals and vars

2009-09-18 Thread Georg Brandl
Georg Brandl added the comment: I'm sorry, I messed up the test. When "x" is not used in g(), it's of course *not* a free variable in g. This is the correct test: def f(): x = 1 def g(): print x print locals() g() f() -- ___ Python t

[issue6925] Doc for locals and vars

2009-09-17 Thread Senthil
Senthil added the comment: On Fri, Sep 18, 2009 at 04:35:37AM +, Terry J. Reedy wrote: > Was 2.x different? Even in 2.x it returns {} And I thought that was expected. Even I am confused by the free variable explaination as you pointed out. Perhaps, Georg could explain better? --

[issue6925] Doc for locals and vars

2009-09-17 Thread Terry J. Reedy
Terry J. Reedy added the comment: Except for the variable name and 3.1 print(), that is exactly what I tested before posting: >>> {} Was 2.x different? Anyway, from Wikipedia: "In computer programming, a free variable is a variable referred to in a function that is not a local variable or an

[issue6925] Doc for locals and vars

2009-09-17 Thread Georg Brandl
Changes by Georg Brandl : -- assignee: -> georg.brandl ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://m

[issue6925] Doc for locals and vars

2009-09-17 Thread Georg Brandl
Georg Brandl added the comment: Free variables *are* returned by locals(). (Note that globals *aren't* free variables.) For example, try this: def f(): x = 1 def g(): print locals() g() f() -- nosy: +georg.brandl ___ Python tracker

[issue6925] Doc for locals and vars

2009-09-17 Thread S Arrowsmith
Changes by S Arrowsmith : -- nosy: +siona ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org

[issue6925] Doc for locals and vars

2009-09-16 Thread Terry J. Reedy
New submission from Terry J. Reedy : Doc for locals(): after correctly stating "Update and return a dictionary representing the current local symbol table. Note The contents of this dictionary should not be modified; changes may not affect the values of local variables used by the interpreter."