[Python-ideas] for/else syntax

Yuvgoog Greenle ubershmekel at gmail.com
Fri Oct 2 14:45:56 CEST 2009

> Nonsense - there are several other ways to break out of a loop. Raising an
> exception or returning for example

I do appreciate your response. I'd like you to examine how the "else" in
question isn't relevant to the discussion of return or raise:

>>> for i in range(10):
...     print(1/0)
... else:
...     print(100)
Traceback (most recent call last):
  File "<stdin>", line 2, in <module>
ZeroDivisionError: int division or modulo by zero
>>> def eggs():
...     for i in range(10):
...             return 1234
...     else:
...             print(69)
>>> eggs()
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20091002/7164c060/attachment.html>

More information about the Python-ideas mailing list