7stud <[EMAIL PROTECTED]> wrote:
   ...
> Can you explain some of the details of why this code fails:
   ...
>     def next(self):
>         for word in "Norwegian Blue's have beautiful
> plumage!".split():
>             yield word

Sure, easily: a loop like "for x in y:" binds an unnamed temporary
variable (say _t) to iter(y) and then repeatedly calls _t.next() [or to
be pedantic type(_t).next(t)] until that raises StopIteration.

Calling a generator, such as this next method, returns an iterator
object; calling it repeatedly returns many such iterator objects, and
never raises StopIteration, thus obviously producing an unending loop.


Alex
-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to