> Given that the OP is talking 2000 files to be processed, I think I'd > recommend explicit open() and close() calls to avoid having lots of I/O > structures floating around...
Good point. I didn't think of that. It could also be done as follows: for fileN in files: lnum = 0 # line number input = file(fileN) for line in input: lnum += 1 if lnum >= 4: break input.close() # do something with "line" Six of one or half a dozen of the other, I suppose. -- http://mail.python.org/mailman/listinfo/python-list