title: NameError while converting tar.gz to zip
body: <p>I got the following code from my question on how to convert the tar.gz file to zip file. </p>
  
  <pre><code>import tarfile, zipfile
  tarf = tarfile.open(name='sample.tar.gz', mode='r|gz' )
  zipf = zipfile.ZipFile.open( name='myzip.zip', mode='a', compress_type=ZIP_DEFLATED )
  for m in tarf.getmembers():
      f = tarf.extractfile( m )
      fl = f.read()
      fn = m.name
      zipf.writestr( fn, fl )
  tarf.close()
  zipf.close()
  </code></pre>
  
  <p>but when I run it I get the error.</p>
  
  <p>What should I change in the code to make it work? </p>
  
  <pre><code>NameError: name 'ZIP_DEFLATED' is not defined
  </code></pre>