[Python-ideas] for/else syntax
Greg Ewing
greg.ewing at canterbury.ac.nz
Sat Oct 3 04:07:04 CEST 2009
Steven D'Aprano wrote:
> try:
> if cond:
> raise ValueError
> else:
> print "no exception was raised"
> finally:
> print "done"
According to the Language Reference, the finally clause protects all of
the preceding clauses in the try statement, including the else clause.
So this would be equivalent to
try:
if cond:
raise ValueError
print "no exception was raised"
finally:
print "done"
--
Greg
More information about the Python-ideas
mailing list