On Wed, 14 Feb 2007 18:03:19 -0800, Paul Rubin wrote: > Steven D'Aprano <[EMAIL PROTECTED]> writes: >> self.isDataLoaded = False >> try: >> f = open(self.filename, 'rb') >> f.seek(DATA_OFFSET) >> self.__data = f.read(DATA_SIZE) >> self.isDataLoaded = True >> except: >> pass >> else: >> pass >> >> (apart from being four lines shorter) > > Your version never closes the file.
Yes it does. Eventually f goes out of scope and is closed automatically. I don't see where the "with" version closes the file either. How does it know that I want to call the f's close() method, rather than, say, f.exit() or f.do_something_else()? -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list