John Salerno <[EMAIL PROTECTED]> writes:
> def create_sql_script(self):
> with open('labtables.sql') as sql_script:
> return sql_script.read()
>
> Does the file still get closed even though I have a return statement
> inside the with block?
Yes, I think so. I'm not running 2.5 yet but this is supposed to be
the idea of the with statement. As for the open failing, you'd deal
with that using try/except around the whole thing.
http://www.python.org/dev/peps/pep-0343/ explains the with statement
in detail.
--
http://mail.python.org/mailman/listinfo/python-list