try/except/else/finally problem
Sebastian Wiesner
basti.wiesner at gmx.net
Thu Jun 28 14:06:32 EDT 2007
[ Ed Jensen <ejensen at visi.com> ]
> try:
> f = file('test.txt', 'r')
> except IOError:
> print 'except'
> else:
> print 'else'
> finally:
> print 'finally'
>
>
> And the results are:
>
> File "./test.py", line 9
> finally:
> ^
> SyntaxError: invalid syntax
A finally block isn't allowed to appear together with an except block for
releases previous to 2.5. You need to split your exception handling into
two separate blocks.
--
Freedom is always the freedom of dissenters.
(Rosa Luxemburg)
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 196 bytes
Desc: This is a digitally signed message part.
URL: <http://mail.python.org/pipermail/python-list/attachments/20070628/0ae4bab0/attachment.sig>
More information about the Python-list
mailing list