Le 21/11/11 06:46, GZ a écrit :
Not testedHi, Here is my situation. A parent object owns a list of files (or other objects with a close() method). The close() method can sometimes fail and raise an exception. When the parent object's close() method is called, it needs to close down as many files it owns as possible, even if the close() function of some files fail. I also want to re-raise at least one of the original exceptions so that the outer program can handle it. def close_all(L): is_not_closed = {} def close_(obj): try: obj.close() except Exception, why is_not_closed[obj] = why for f in L: close_(f) Now, your dictionnary contain the file as key and the exception message as value. |
-- http://mail.python.org/mailman/listinfo/python-list
