Jeff Hall schrieb:
> I realized after I fired off my response that this was still bugging
> me... it appears that the documentation is incorrect
>
> from 2.1 Built-in Functions (v2.5 in case it matters... a quick search
> of bugs doesn't seem to show anything though)
>
> *reversed*( seq)
>
>
From: "Armin Ronacher" <[EMAIL PROTECTED]>
len(ri)
4
ri.next()
4
len(ri)
3
This is the only reverse iterator with that sort of behavior.
Use the bug tracker please and assign to me.
At one time, some iterators had the ability to know
their own length and that would change as the
iterato
Jeff Hall gmail.com> writes:
> reversed(
> seq)
> Return a reverse iterator. seq must be an object which
> supports the sequence protocol (the __len__() method and the __getitem__()
method with integer arguments starting at
> 0). New in version 2.4. the above appears to only be true for lists.
I realized after I fired off my response that this was still bugging me...
it appears that the documentation is incorrect
from 2.1 Built-in Functions (v2.5 in case it matters... a quick search of
bugs doesn't seem to show anything though)
*reversed*( seq) Return a reverse iterator. seq must be a
Unless I'm misconstruing something the problem is that reversed returns two
different object types depending on if it's a list or a tuple
>>> l = [1,2,3,4]
>>> i = iter(l)
>>> ri = reversed(l)
>>> l
[1, 2, 3, 4]
>>> ri
>>> i
>>> t = (1,2,3,4)
>>> it = iter(t)
>>> rit = reversed(t)
>>> it
>>> ri
Hi,
I stumbled upon a confusing listreverseiterator behavior:
>>> l = [1, 2, 3, 4]
>>> i = iter(l)
>>> ri = reversed(l)
>>> len(i)
Traceback (most recent call last):
File "", line 1, in
TypeError: object of type 'listiterator' has no len()
>>> len(ri)
4
>>> ri.next()
4
>>> len(ri)
3
This is t