New submission from Theodoros Ikonomou:
I find the code presented as equivalent for itertools.combinations is overly
complex.
I think we can change it to something easier like the following:
def combinations(iterable, r):
i, size = 0, len(iterable)
while i + r - 1 < size:
subindex = i+1
while subindex + r - 2 < size:
yield (iterable[i],) + tuple(iterable[subindex:subindex+r-1])
subindex += r - 1
i += 1
--
assignee: docs@python
components: Documentation
messages: 187566
nosy: Theodoros.Ikonomou, docs@python
priority: normal
severity: normal
status: open
title: itertools.combinations example is overly complicated
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2, Python 3.3, Python
3.4, Python 3.5
___
Python tracker
<http://bugs.python.org/issue17815>
___
___
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com