code: def close(self):
          
          if self._mode == _MODE_CLOSED:
              return
          try:
              if self._mode in (_MODE_READ, _MODE_READ_EOF):
                  self._decompressor = None
                  self._buffer = None
              elif self._mode == _MODE_WRITE:
                  self._fp.write(self._compressor.flush())
                  self._compressor = None
          finally:
              try:
                  if self._closefp:
                      self._fp.close()
              finally:
                  self._fp = None
                  self._closefp = False
                  self._mode = _MODE_CLOSED
docs: Flush and close the file.
  
          May be called more than once without error. Once the file is
          closed, any other operation on it will raise a ValueError.