Opening files without closing them

3c273 nospam at
Wed Mar 8 19:55:15 CET 2006

"Bryan" <belred at> wrote in message
news:mailman.2870.1141783685.27775.python-list at
> if i really want to handle the exception, then i handle it at a
> "higher" level by wrapping it in an exception which is basically what some
> higher-level routine would do anyways.
> try:
>      f = open('file)
>      try:
>          # do something
>      finally:
>          f.close()
> except IOError:
>      # handle exceptions
I like this idea also. Thanks to all who helped me understand..

More information about the Python-list mailing list