[Python-ideas] for/else syntax
fuzzyman at gmail.com
Fri Oct 2 18:12:25 CEST 2009
2009/10/2 Arnaud Delobelle <arnodel at googlemail.com>
> On 2 Oct 2009, at 15:43, Steven D'Aprano wrote:
>> Perhaps there should be. Does anyone know why there isn't? It seems an
>> arbitrary restriction to me, because the following pieces of code are
>> not equivalent:
>> # not currently legal
>> if cond:
>> raise ValueError
>> print "no exception was raised"
>> print "done"
>> But the above is the same as:
> if cond:
> raise ValueError
> print "no exception was raised"
> print "done"
But as always with Python, the code in the else clause is not protected by
the except so that you do not incorrectly handle unexpected exceptions.
> Python-ideas mailing list
> Python-ideas at python.org
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas