Roel Schroeven a écrit : > Fredrik Lundh schreef: >> so what is a valid answer? > > > I think he wants to know why the spec has been written that way. > > The rationale mentions exhausted iterators: > > "Once a particular iterator object has raised StopIteration, will > it also raise StopIteration on all subsequent next() calls? > Some say that it would be useful to require this, others say > that it is useful to leave this open to individual iterators. > Note that this may require an additional state bit for some > iterator implementations (e.g. function-wrapping iterators). > > Resolution: once StopIteration is raised, calling it.next() > continues to raise StopIteration." > > This doesn't, however, completey answer the OP's question, I think. It > is about raising or not raising StopIteration on subsequent next() calls > but doesn't say anything on possible alternatives, such as raising > another exception (I believe that's what the OP would like).
Exactly ! > Not that I know of use cases for other exceptions after StopIteration; > just clarifying what I think the OP means. There are no use cases yet for me. I want those exceptions as an hard error for debuging purposes. -- http://mail.python.org/mailman/listinfo/python-list