which one of these is better?

John Salerno johnjsal at NOSPAMgmail.com
Thu Oct 26 14:12:03 EDT 2006


John Salerno wrote:

>     def create_sql_script(self):
>         try:
>             f = open('labtables.sql')
>             sql_script = f.read()
>         except IOError:
>             wx.MessageBox('Could not locate the file "labtables.sql"',
>                           'File Not Found')
>         finally:
>             f.close()

Hmm, looks like this doesn't work anyway if open() doesn't work, because 
then f.close() raises an UnboundLocalError for obvious reasons.



More information about the Python-list mailing list