Neil Cerutti <[EMAIL PROTECTED]> wrote: > On 2007-12-07, Duncan Booth <[EMAIL PROTECTED]> wrote: >> from __future__ import with_statement >> >> def loaddomainowners(domain): >> with open('/etc/virtual/domainowners','r') as infile: > > I've been thinking I have to use contextlib.closing for > auto-closing files. Is that not so? > That is not so.
Python 2.5.1 (r251:54863, Apr 18 2007, 08:51:08) [MSC v.1310 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> from __future__ import with_statement >>> with open('diffs.txt') as f: ... print len(list(f)) ... 40 >>> f <closed file 'diffs.txt', mode 'r' at 0x00AA0698> >>> -- http://mail.python.org/mailman/listinfo/python-list