[New-bugs-announce] [issue27678] itertools.permutations/.combinations should have len

Claudiu Saftoiu report at bugs.python.org
Thu Aug 4 03:25:07 EDT 2016


New submission from Claudiu Saftoiu:

Right now, itertools.permutations and itertools.combinations and itertools.product objects don't have a `len`. 

    >>> len(itertools.combinations(range(10), 5))
    Traceback (most recent call last):
      File "<stdin>", line 1, in <module>
    TypeError: object of type 'itertools.combinations' has no len()

I propose that a `len` be added to them, which computes (& caches) & returns the length. If the underlying iterator doesn't have a length, then they can raise a TypeError as they do now.

----------
messages: 271952
nosy: Claudiu Saftoiu
priority: normal
severity: normal
status: open
title: itertools.permutations/.combinations should have len
type: enhancement
versions: Python 3.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue27678>
_______________________________________


More information about the New-bugs-announce mailing list