diff --git a/Lib/dataset.py b/Lib/dataset.py index b95a4bfc..e7558bad 100644 --- a/Lib/dataset.py +++ b/Lib/dataset.py @@ -1204,6 +1204,10 @@ def __init__(self, path, mode, hostObj=None, mpiBarrier=False): self.close() raise + def __enter__(self): + return self; + def __exit__(self, type, value, traceback): + self.close() # setattr writes external global attributes to the file def __setattr__(self, name, value): self.__dict__[name] = value # attributes kept in sync w/file