There's always the new 'with' statement in Python 2.5. So instead of
> f = open('foo', 'r')
> try:
>for line in f:
> print line
> finally:
>f.close()
>
...you do:
with open('foo','r') as f:
for line in f:
print line
It's at least a little bit cleaner, and it will close the file if there's an
exception as well.
(See http://docs.python.org/dev/whatsnew/pep-343.html and don't forget to
include
from __future__ import with_statement
at the top of the file)
--
http://mail.python.org/mailman/listinfo/python-list