[issue19202] Additions to docs

2013-10-09 Thread Esa Peuha
New submission from Esa Peuha: Here are some additions to documentation of a few functions: all, any: alternative definitions using functools.reduce enumerate: alternative definition using zip and itertools.count sum: equivalent definition using functools.reduce and operator.add

[issue19202] Additions to docs

2013-10-09 Thread Georg Brandl
Georg Brandl added the comment: Most of these changes should not be applied: the alternate equivalents in terms of reduce() will not help understanding, Equivalents for reduce() may be useful, but I would limit them to one per case, possibly even just one function that covers both cases.

[issue19202] Additions to docs

2013-10-09 Thread Esa Peuha
Esa Peuha added the comment: How would you give a single definition of reduce() that helps people to understand both 2-arg and 3-arg variants? The way it is implemented in C is impossible to duplicate in pure Python; the best you could do is a hack that works unless someone *tries* to break

[issue19202] Additions to docs

2013-10-09 Thread Georg Brandl
Georg Brandl added the comment: What about def reduce(function, iterable, initializer=None): it = iter(iterable) if initializer is None: value = next(it) else: value = initializer for element in it: value = function(value, element) return value