Issue3689
Created on 2008-08-26 20:17 by laxrulz777, last changed 2008-08-26 20:42 by aronacher.
| msg71993 (view) |
Author: Jeff Hall (laxrulz777) |
Date: 2008-08-26 20:17 |
|
reversed() built in is not functioning correctly with list (specifically
with len() )
l = [1,2,3,4]
rl = reversed(l)
type(rl)
<type 'listreverseiterator'>
vs. strings and tuples which just return 'reverse' objects
listreverseiterators apparently have a len() defined that changes with
each .next() call
|
| msg71994 (view) |
Author: Georg Brandl (georg.brandl) |
Date: 2008-08-26 20:27 |
|
"reversed() built in is not functioning correctly with list" is wrong --
there is no problem with reversed() on lists.
The issue here is that the listreverseiterator has a strange __len__.
Note that other (reverse) iterators have no __len__ at all, so apart
from consistency there is nothing that "does not function correctly."
|
| msg71995 (view) |
Author: Armin Ronacher (aronacher) |
Date: 2008-08-26 20:42 |
|
Just for the record. This original discussion for this bug is here:
http://article.gmane.org/gmane.comp.python.devel/96925
|
|
| Date |
User |
Action |
Args |
| 2008-08-26 20:42:56 | aronacher | set | nosy:
+ aronacher messages:
+ msg71995 |
| 2008-08-26 20:31:48 | georg.brandl | set | assignee: rhettinger title: reversed() not working as intended on lists -> listreverseiterator has a decreasing len() nosy:
+ rhettinger versions:
+ Python 2.6, Python 3.0, - Python 2.5 |
| 2008-08-26 20:27:24 | georg.brandl | set | priority: low nosy:
+ georg.brandl messages:
+ msg71994 |
| 2008-08-26 20:17:14 | laxrulz777 | create | |
|