What makes an iterator an iterator?

Isaac Rodriguez isaac.rodriguez at comcast.net
Wed Apr 18 09:26:40 EDT 2007


>
> class Parrot(object):
>     def __iter__(self):
>         return self
>     def __init__(self):


Typo right here!!!!

>         self.next = self._next()

write:
            self.next = self._next

no parenthesis.

>     def _next(self):
>         for word in "Norwegian Blue's have beautiful plumage!".split():
>             yield word
>


See previous explanation.

thanks,

- Isaac.




More information about the Python-list mailing list