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 Anran Yang
Recipients Anran Yang, docs@python
Date 2017-09-25.12:11:35
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
At the end of the Functional Programming HOWTO document ( the usage of reduce/lambda/for loops are compared and discussed. However, the example for reduce seems sub-optimal and thus the discussion is not that efficient. The example:

total = functools.reduce(lambda a, b: (0, a[1] + b[1]), items)[1]

could be changed to:

total = functools.reduce(lambda total, item: total + item[1], items, 0)

which is much more readable and is actually not much inferior to the loop one (though the sum approach is still more concise).
Date User Action Args
2017-09-25 12:11:36Anran Yangsetrecipients: + Anran Yang, docs@python
2017-09-25 12:11:35Anran Yangsetmessageid: <>
2017-09-25 12:11:35Anran Yanglinkissue31575 messages
2017-09-25 12:11:35Anran Yangcreate