Nick Coghlan <[EMAIL PROTECTED]> wrote: > 5. Several builtin functions return iterators rather than lists, specifically > xrange(), enumerate() and reversed(). Other builtins that yield sequences > (range(), sorted(), zip()) return lists.
Yes for enumerate and reversed, no for xrange: >>> xx=xrange(7) >>> xx.next() Traceback (most recent call last): File "<stdin>", line 1, in ? AttributeError: 'xrange' object has no attribute 'next' >>> it SHOULD return an iterator, no doubt, but it doesn't (can't, for backwards compatibility reasons). Neither does it return a list: it returns "an `xrange' object", a specialized type that's not an iterator, though it's iterable. It's a type, btw: >>> xrange <type 'xrange'> >>> so it's not surprising that calling it returns instances of it (enumerate and reversed are also types, but *WITH* 'next'...). Alex -- http://mail.python.org/mailman/listinfo/python-list