"Steven D'Aprano" <[EMAIL PROTECTED]> escribió en el mensaje news:[EMAIL PROTECTED]
> On Fri, 26 Jan 2007 17:25:37 +0100, Bruno Desthuilliers wrote: >>> def __del__(self): >>> try: >>> self.close() >>> finally: >>> pass >>> except: >>> pass >> >> The finally clause is useless here. > > In principle, closing a file could raise an exception. I've never seen it > happen, but it could. From the Linux man pages: [...] > I assume that the same will apply in Python. Note that he said that the *finally* clause were useless (and I'd say so, too), not the *except* clause. And yes, in Python it is checked - when the close method was called explicitely, an exception is raised; when called when the object is garbage collected, a message is printed on sys.stderr > It has to be said, however, that the error recovery shown ("pass") is > fairly pointless :-) Only supresses the message on sys.stderr - exceptions raised on __del__ are never propagated. -- Gabriel Genellina -- http://mail.python.org/mailman/listinfo/python-list