Newbie question about exceptions

Fredrik Lundh effbot at telia.com
Tue Feb 22 04:35:06 EST 2000


Remco Gerlich <scarblac-spamtrap at pino.selwerd.nl> wrote:
> How about:
>
> try:
>     f1 = open(file1)
> (etc)
> except:
>     print 'File open error'
> f1.close()
>
> It will always get there.

File open error
Traceback (innermost last):
  File "bzzt.py", line 5, in ?
NameError: f1

(the original example was thrice
as flawed, of course ;-)

</F>





More information about the Python-list mailing list