#1286: allow using fileinput.FileInput as context manager.

This commit is contained in:
Georg Brandl 2010-07-31 20:08:15 +00:00
parent e42a59daec
commit 6cb7b6593e
4 changed files with 59 additions and 7 deletions

View file

@ -238,6 +238,12 @@ class FileInput:
self.nextfile()
self._files = ()
def __enter__(self):
return self
def __exit__(self, type, value, traceback):
self.close()
def __iter__(self):
return self