This week only. Pastebin PRO Accounts Christmas Special! Don't miss out!Want more features on Pastebin? Sign Up, it's FREE!


By: a guest on Mar 28th, 2012  |  syntax: Python  |  size: 0.27 KB  |  views: 18  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. from itertools import izip_longest
  2. from contextlib import nested
  4. names = ('file1', 'file2')
  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()
clone this paste RAW Paste Data