[Python-ideas] for/else syntax

Arnaud Delobelle arnodel at googlemail.com
Fri Oct 2 18:00:38 CEST 2009


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
> try:
>    if cond:
>        raise ValueError
> else:
>    print "no exception was raised"
> finally:
>    print "done"
>
>
But the above is the same as:

try:
     if cond:
        raise ValueError
     print "no exception was raised"
finally:
     print "done"

> versus:
[...]

-- 
Arnaud





More information about the Python-ideas mailing list