Newbie question about exceptions
scarblac-spamtrap at pino.selwerd.nl
Tue Feb 22 02:41:02 CET 2000
Vijay Baliga wrote in comp.lang.python:
> Why isn't "finally" allowed with "try/except"?
Everything with "except:" is done if that exception is matched. A
"finally:" clause is executed regardless of whether an exception
was raised. If you have an "except:" clause already, that's quite
Ideally, I would like to do
> the following:
> f1 = open(file1)
> f2 = open(file2)
> use(f1, f2)
> f3 = open(file3)
> use(f1, f2, f3)
> print 'File open error'
f1 = open(file1)
print 'File open error'
It will always get there.
(Of course, no need to close files - it'll be done automatically after the
file leaves scope, because of refcounting)
Remco Gerlich, scarblac at pino.selwerd.nl
"Early to rise, early to bed, makes a man healthy, wealthy and dead." -- TP
More information about the Python-list