This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author iMath
Recipients docs@python, iMath
Date 2017-04-09.06:16:55
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1491718615.9.0.544401247511.issue30023@psf.upfronthosting.co.za>
In-reply-to
Content
There example code here becomes invalid 
https://docs.python.org/3/faq/programming.html#why-do-lambdas-defined-in-a-loop-with-different-values-all-return-the-same-result
>>> squares = []
>>> for x in range(5):
	squares.append(lambda: x**2)

	
>>> squares
[<function <lambda> at 0x01FB7A08>, <function <lambda> at 0x01F82390>, <function <lambda> at 0x01FBA3D8>, <function <lambda> at 0x01FBA420>, <function <lambda> at 0x01FBA468>]
>>> 

There returned value is a List of lambda functions, not numbers
History
Date User Action Args
2017-04-09 06:16:55iMathsetrecipients: + iMath, docs@python
2017-04-09 06:16:55iMathsetmessageid: <1491718615.9.0.544401247511.issue30023@psf.upfronthosting.co.za>
2017-04-09 06:16:55iMathlinkissue30023 messages
2017-04-09 06:16:55iMathcreate