Skip to content

Commit 30b66fa

Browse files
committed
Add __enter__ and __exit__ methods.
1 parent 4d718ec commit 30b66fa

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

wfdb/io/archive.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,12 @@ def __init__(self, record_name, mode="r"):
5050
pass # Just create the file
5151
self.zipfile = zipfile.ZipFile(self.archive_path, mode="a")
5252

53+
def __enter__(self):
54+
return self
55+
56+
def __exit__(self, exc_type, exc_val, exc_tb):
57+
self.close()
58+
5359
def exists(self, filename):
5460
"""
5561
Check if a file exists in the archive.

0 commit comments

Comments
 (0)