SHARE
TWEET

Untitled

a guest Mar 28th, 2012 19 Never
  1. from itertools import izip_longest
  2. from contextlib import nested
  3.  
  4. names = ('file1', 'file2')
  5.  
  6. with nested(*map(open, names)) as files:
  7.     for line in (line for pair in izip_longest(*files)
  8.                       for line in pair if line):
  9.         print line.strip()
RAW Paste Data
Top