[issue19202] Additions to docs
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 functools.reduce: equivalent definitions, use operator.add in example itertools.accumulate: point to functools.reduce itertools.filterfalse: point to filter -- assignee: docs@python components: Documentation files: doc.diff keywords: patch messages: 199281 nosy: Esa.Peuha, docs@python priority: normal severity: normal status: open title: Additions to docs type: enhancement versions: Python 3.4 Added file: http://bugs.python.org/file32013/doc.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19202 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19202] Additions to docs
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. I'm deferring to Raymond for the changes to the itertools docs. -- nosy: +georg.brandl, rhettinger ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19202 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19202] Additions to docs
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 it, but that would just be confusing. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19202 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue19202] Additions to docs
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 Remember, an equivalent doesn't have to be 100% compatible, it is a way for the user to quickly get an idea what the function does. -- ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue19202 ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com