try/except/else/finally problem

Ed Jensen ejensen at
Thu Jun 28 21:13:17 CEST 2007

Peter Otten <__peter__ at> wrote:

>> try:
>>     f = file('test.txt', 'r')
>> except IOError:
>>     print 'except'
>> else:
>>     print 'else'
>> finally:
>>     print 'finally'

> You need Python 2.5 for that to work. In older Python versions you have to
> nest try...except...else and try...finally.

Thanks Peter.

Given the code above, can you show me what that would look like?  The
nested version, that is.

More information about the Python-list mailing list