On Thu, Jan 23, 2014 at 10:50 AM, Keith Winston <keithw...@gmail.com> wrote:
> On Thu, Jan 23, 2014 at 7:05 AM, eryksun <eryk...@gmail.com> wrote:
>> Generally you'll make `__iter__` a generator, so you don't have to
>> worry about implementing `__next__`. Also, the built-in function
>> `next` was added in 2.6, so you don't have to worry about the method
>> name difference between 2.x and 3.x, either.
>
> Yes, the exercise was about implementing an iter incorrectly, to see
> the difference. But I don't really understand your second point: when
> I changed the method name, it worked...?

The page you sited discusses iterating the "old-fashioned way" in a
loop that calls `some_iter.next()`. Nowadays it's `next(some_iter)`,
which works in 2.6+ and 3.x. So if `__iter__` is a generator, you
don't implement '__next__` and generally won't have to call it
explicitly -- unless for some reason you need to pass the bound method
as a callable.
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to