Permalink
Browse files

ENH: add close method and context manager support to IO

  • Loading branch information...
1 parent 5b621ae commit 78606f15033c8ff10965eace98456fb79bb8cbf3 @cgohlke cgohlke committed Oct 16, 2013
Showing with 9 additions and 0 deletions.
  1. +9 −0 la/io.py
View
@@ -180,6 +180,15 @@ def merge(self, key, lar, update=False):
lar2 = lar1.merge(lar, update=update)
del self.f[key]
self[key] = lar2
+
+ def close(self):
+ self.f.close()
+
+ def __enter__(self):
+ return self
+
+ def __exit__(self, exc_type, exc_value, traceback):
+ self.close()
def __iter__(self):
return iter(self.keys())

0 comments on commit 78606f1

Please sign in to comment.