diff options
Diffstat (limited to 'numpy/lib/io.py')
-rw-r--r-- | numpy/lib/io.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/numpy/lib/io.py b/numpy/lib/io.py index 6edf902e3..9e61ab2f8 100644 --- a/numpy/lib/io.py +++ b/numpy/lib/io.py @@ -8,7 +8,6 @@ __all__ = ['savetxt', 'loadtxt', import numpy as np import format -import zipfile import cStringIO import tempfile import os @@ -42,6 +41,9 @@ class NpzFile(object): with .files and the ZipFile object itself using .zip """ def __init__(self, fid): + # Import is postponed to here since zipfile depends on gzip, an optional + # component of the so-called standard library. + import zipfile _zip = zipfile.ZipFile(fid) self._files = _zip.namelist() self.files = [] @@ -165,6 +167,10 @@ def savez(file, *args, **kwds): arr_0, arr_1, etc. """ + # Import is postponed to here since zipfile depends on gzip, an optional + # component of the so-called standard library. + import zipfile + if isinstance(file, str): if not file.endswith('.npz'): file = file + '.npz' |