What makes an iterator an iterator?

Ben Finney bignose+hates-spam at benfinney.id.au
Wed Apr 18 02:58:23 EDT 2007


Steven D'Aprano <steve at REMOVEME.cybersource.com.au> writes:

> class Parrot(object):
>     def __iter__(self):
>         return self
>     def __init__(self):
>         self.next = self._next()
>     def _next(self):
>         for word in "Norwegian Blue's have beautiful plumage!".split():
>             yield word

Clearly the problem is you've misused an apostrophe. Python doesn't
like the plural getting an apostrophe.

    <URL:http://www.angryflower.com/bobsqu.gif>

-- 
 \          "Speech is conveniently located midway between thought and |
  `\     action, where it often substitutes for both."  -- John Andrew |
_o__)                                  Holmes, _Wisdom in Small Doses_ |
Ben Finney



More information about the Python-list mailing list