[Tutor] iterators

Keith Winston keithwins at gmail.com
Sun Jan 19 00:24:58 CET 2014


On Sat, Jan 18, 2014 at 2:19 PM, eryksun <eryksun at gmail.com> wrote:
> `xrange` and 3.x `range` aren't iterators. They're sequences. A
> sequence implements `__len__` and `__getitem__`, which can be used to
> implement an iterator, reversed iterator, and the `in` operator (i.e.
> `__contains__`).

I'm so glad you said this, I'm sorta burned out right now trying to
read all this, and I got sorta confused by that part. But what you're
saying is what I thought I understood.

Okay, now your example is pretty interesting. I guess it makes sense
that iter() returns a type iterator. Sure, of course.

Thanks as always to everyone, this is a trove. I'm a bit under the
weather so I'll have to come back and read it closer. I'm a little
clearer, though, and not just on iterators...

-- 
Keith


More information about the Tutor mailing list