What about:
import contextlib
def unzip(source, target):
with contextlib.closing(zipfile.ZipFile(source , "r")) as z:
z.extractall(target)
print "Extracted : " + source + " to: " + target
contextlib.closing
does exactly what the missing __exit__
method on the ZipFile
would be supposed to do. Namely, call the close
method