[docs] Need Programming FAQ entry for the behavior of closures (issue 13094)
rdmurray at bitdance.com
rdmurray at bitdance.com
Fri Jan 4 19:08:50 CET 2013
Thanks for writing this. Overall it looks good, but I did some copy
editing. Only two substantive comments.
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst
File Doc/faq/programming.rst (right):
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode219
Doc/faq/programming.rst:219: This gives you a list that contains 5
lambdas that calculate ``x**2``, and you
...``x**2``. You...
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode220
Doc/faq/programming.rst:220: might expect that, when called, they would
return respectively ``0``, ``1``,
commas around respectively (IMO)
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode221
Doc/faq/programming.rst:221: ``4``, ``9``, and ``16``. However, when
you actually try, you will see that
I think the comma after try is unnecessary and a bit distracting (though
not technically wrong).
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode229
Doc/faq/programming.rst:229: This happens because ``x`` is not local to
the lambdas, but it's defined in
is instead of "it's".
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode230
Doc/faq/programming.rst:230: the global scope, and it's accessed when
the lambda is called --- not when it's
How about you just say "outer scope" here, which will cover the case of
referencing a local inside a function.
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode230
Doc/faq/programming.rst:230: the global scope, and it's accessed when
the lambda is called --- not when it's
I would prefer spelling out 'it is' here.
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode233
Doc/faq/programming.rst:233: changing the value of ``x`` and see how the
result of the lambdas changes::
changes should be change. Probably result should be results.
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode246
Doc/faq/programming.rst:246: Here, ``n=x`` creates a new variable ``n``
local to the lambda, with the
Rather than say "local to the lambda", I think it would be more correct
to say "whose value is computed when the lambda is defined", which is
what is really going on here.
http://bugs.python.org/review/13094/diff/6975/Doc/faq/programming.rst#newcode256
Doc/faq/programming.rst:256: Note that this is not a particular
behaviour of lambdas, but it applies to
"this behavior is not peculiar to lambdas, but applies..."
http://bugs.python.org/review/13094/
More information about the docs
mailing list