On Jun 21, 9:00 pm, Robert Hicks <[EMAIL PROTECTED]> wrote:
> Is it good practice to do something like:
>
> try:
>     f1 = file('file1')
>     f2 = file('file2')
> except:
>     # catch the exception

It's bad practice. Because you use a bare except clause, and don't do
anything useful with the exceptions you catch.

> Or do you do a try/except for each open?

If what you want is to make sure that resources will be released, you
can use a try/finally block or (Python 2.5) a with block.



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

Reply via email to