[issue26683] Questionable terminology for describing what locals() does

2016-12-12 Thread Marco Buttu
Marco Buttu added the comment: Another point in the doc, where the meaning of "free variable" is inconsistent with the ``locals()`` and ``code.co_freevars`` meaning: https://docs.python.org/3/reference/executionmodel.html#interaction-with-dynamic-features --

[issue26683] Questionable terminology for describing what locals() does

2016-12-03 Thread Marco Buttu
Marco Buttu added the comment: The documentation [1] says: "If a variable is used in a code block but not defined there, it is a free variable." According to this description, it seems to me that the variable ``x`` is free in ``foo()``:: >>> def foo(): ... print(x) But actually for

[issue26683] Questionable terminology for describing what locals() does

2016-04-01 Thread Terry J. Reedy
Terry J. Reedy added the comment: I requested that we stop (mis)using 'free variable' in the docs years ago. A strong +1 from me. The 'locals' function what named when 'local' and 'non-global' were synonyms. When non-local, non-global names were added, nonlocals were included with 'locals'

[issue26683] Questionable terminology for describing what locals() does

2016-03-31 Thread Raymond Hettinger
Raymond Hettinger added the comment: > A national variable maybe :) I would think that "nonlocal" is exactly the right term given that that is how you would declare it if you wanted to write to it. >>> w = 5 >>> def f(x): def g(y): nonlocal x global w

[issue26683] Questionable terminology for describing what locals() does

2016-03-31 Thread Martin Panter
Martin Panter added the comment: Regarding “free variables”, in Issue 17546 I proposed the wording “. . . also includes non-local, non-global names”. In your code example, I would consider y to be 100 percent local to the g() function. It is a function parameter, and “y += 1” should work. I

[issue26683] Questionable terminology for describing what locals() does

2016-03-31 Thread Raymond Hettinger
New submission from Raymond Hettinger: The docs for locals() say that inside a function that local variables and free variables are included: https://docs.python.org/3/library/functions.html#locals Elsewhere we use the terms "cell variables" or "nonlocals". Mathematically, the word "free"