[issue32065] range_iterator doesn't have length, leads to surprised result

2017-11-17 Thread R. David Murray
R. David Murray added the comment: By design, iterators do not have a length (see msg248496). -- nosy: +r.david.murray resolution: -> not a bug stage: -> resolved status: open -> closed ___ Python tracker

[issue32065] range_iterator doesn't have length, leads to surprised result

2017-11-17 Thread yegle
yegle added the comment: Hmm I think this also applies to list_listiterator. In general I'd expect these to be true: l = [1,2,3] r = range(3) assert len(l) == len(reversed(l)) assert len(r) == len(reversed(r)) -- ___ Python

[issue32065] range_iterator doesn't have length, leads to surprised result

2017-11-17 Thread STINNER Victor
Change by STINNER Victor : -- versions: +Python 3.7 ___ Python tracker ___ ___

[issue32065] range_iterator doesn't have length, leads to surprised result

2017-11-17 Thread yegle
New submission from yegle : This also affects xrange in Python2, so I chose the affected version as python27. range object (and xrange in Python2) has __len__(), but the range_iterator object created from __reversed__() doesn't have __len__. Python2: >>> x = xrange(10) >>>