diff --git a/iterators.html b/iterators.html index 8da4842..6388efc 100755 --- a/iterators.html +++ b/iterators.html @@ -177,7 +177,7 @@ All three of these class methods, __init__, __iter__, self.a, self.b = self.b, self.a + self.b return fib
    -
  1. To build an iterator from scratch, fib needs to be a class, not a function. +
  2. To build an iterator from scratch, Fib needs to be a class, not a function.
  3. “Calling” Fib(max) is really creating an instance of this class and calling its __init__() method with max. The __init__() method saves the maximum value as an instance variable so other methods can refer to it later.
  4. The __iter__() method is called whenever someone calls iter(fib). (As you’ll see in a minute, a for loop will call this automatically, but you can also call it yourself manually.) After performing beginning-of-iteration initialization (in this case, resetting self.a and self.b, our two counters), the __iter__() method can return any object that implements a __next__() method. In this case (and in most cases), __iter__() simply returns self, since this class implements its own __next__() method.
  5. The __next__() method is called whenever someone calls next() on an iterator of an instance of a class. That will make more sense in a minute.