[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread R. David Murray
R. David Murray added the comment: It may be time to create a faq entry about len and itertools; it seems to be a very popular idea. For various reasons (documented in several issues in this tracker now), we are not going to add len to the iterators in itertools. See issue 24849, and in parti

[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread Stéphane Wirtel
Stéphane Wirtel added the comment: __length_hint__ returns an estimated length for the object. As you said, if the object passed-in has a length, we could use it. If not, then raise TypeError. But we will have two different behaviors in function of the parameter. -- nosy: +matrixise

[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread Claudiu Saftoiu
Claudiu Saftoiu added the comment: Ahh, I see. In that case, if the object passed-in has a length, use that. If not, then raise TypeError. e.g. proposed behavior: >>> len(itertool.combinations(range(10), 2)) 45 >>> len(itertool.combinations(iter(range(10)), 2)) ... TypeError: itertools.combinat

[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread Xiang Zhang
Changes by Xiang Zhang : -- nosy: +rhettinger ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: https://mail.pyth

[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread Xiang Zhang
Xiang Zhang added the comment: You have to exhausts the iterator to get the actual length. Some iterators have __length_hint__ but it's not required to give the truth. -- nosy: +xiang.zhang ___ Python tracker

[issue27678] itertools.permutations/.combinations should have len

2016-08-04 Thread Claudiu Saftoiu
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 "", line 1, in TypeError: object of type