Skip to content

Instantly share code, notes, and snippets.

@nickjacob
Created February 14, 2013 20:43
Show Gist options
  • Save nickjacob/4956237 to your computer and use it in GitHub Desktop.
Save nickjacob/4956237 to your computer and use it in GitHub Desktop.
open multiple files in with statement
from contextlib import contextmanager
@contextmanager
def files(*ff):
fi = [ open(*f) if len(f) == 2 else open(f) for f in ff ]
yield(fi)
map(close,fi)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment