Advertisement
Guest User

Untitled

a guest
Mar 28th, 2012
61
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.27 KB | None | 0 0
  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()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement