[Python-checkins] r50525 - sandbox/trunk/Doc/functional.rst
andrew.kuchling
python-checkins at python.org
Mon Jul 10 19:16:53 CEST 2006
Author: andrew.kuchling
Date: Mon Jul 10 19:16:53 2006
New Revision: 50525
Modified:
sandbox/trunk/Doc/functional.rst
Log:
Add further development using sum
Modified: sandbox/trunk/Doc/functional.rst
==============================================================================
--- sandbox/trunk/Doc/functional.rst (original)
+++ sandbox/trunk/Doc/functional.rst Mon Jul 10 19:16:53 2006
@@ -870,6 +870,10 @@
for a, b in items:
total += b
+Or the ``sum()`` built-in and a generator expression::
+
+ total = sum(b for a,b in items)
+
Many uses of ``reduce()`` are clearer when written as ``for`` loops.
Fredrik Lundh once suggested the following set of rules for refactoring
More information about the Python-checkins
mailing list