"Peter Hansen" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
>
> So this is better, though probably excessive in small scripts:
>
> try:
>      f = open('file')
> except IOError:
>      # do something else
> else:
>      try:
>          content = f.read()
>      finally:
>          f.close()
>
> This takes advantage of "else" on try statements, which executes only if
> the except statement is not executed.
>
Thank you for your reply. I had forgotten that you could use 'else' in a
'try' statement. I like this solution. Thanks again.
Louis


-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to