Replying to my own question... On Thu, 15 Feb 2007 13:17:00 +1100, Steven D'Aprano wrote:
> 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()? Ah, I *think* I see... file objects in Python 2.5 are objects that know how to work with the "with" statement; that is they obey the "context management" protocol and have __enter__ and __exit__ methods that do the right thing to make everything work correctly. http://docs.python.org/whatsnew/pep-343.html Have I got it right? -- Steven D'Aprano -- http://mail.python.org/mailman/listinfo/python-list