title: How to set a folder destination for a zip-file on python?
body: <p>I'm using zipfile to compress a folder that contains different files. It works well. My only problem is that it creates the zipped file into the root folder where I'm executing the code. How can I tell the folder destination where I want the zipped file?</p>
  
  <p>My code example is this one:</p>
  
  <pre><code># Zips an entire directory using zipfile ----------------------------
  def make_zipfile(_path):
      import zipfile
      if os.path.isdir(_path):
          inName = os.path.basename(_path) + '.zip'
          #head, tail = os.path.split(os.path.split(_path)[0])
          print "saving: " + inName
          def zipdir(_path, zip_handle):
              for root, dirs, files in os.walk(_path):
                  for file in files:
                      print os.path.join(root, file)
                      zip_handle.write(os.path.join(root, file), file)
          with zipfile.ZipFile(inName, 'w', compression=zipfile.ZIP_DEFLATED, allowZip64=True) as z:
              zipdir(_path, z)
      print "zip file created"
      return inName
  </code></pre>