Try the following (Python 2.5.x): import logging
t=open(filename,'rb') try: data=t.read() #processing data... except: logging.exception("Failed to process %r", filename) finally: t.close() For earlier versions of Python, you will need to nest the try blocks: import logging t=open(filename,'rb') try: try: data=t.read() #processing data... except: logging.exception("Failed to process %r", filename) finally: t.close() Regards, Vinay Sajip -- http://mail.python.org/mailman/listinfo/python-list