Zipping only files in Python
<p>So I create several files in some temp directory dictated by NamedTemporaryFile function. </p>

<pre><code>zf = zipfile.ZipFile( zipPath, mode='w' )
for file in files:
    with NamedTemporaryFile(mode='w+b', bufsize=-1, prefix='tmp') as tempFile:
       tempPath = tempFile.name
    with open(tempPath, 'w') as f:
       write stuff to tempPath with contents of the variable 'file'
    zf.write(tempPath)

zf.close()
</code></pre>

<p>When I use the path of these files to add to a zip file, the temp directories themselves get zipped up.<br>
When I try to unzip, I get a series of temp folders, which eventually contain the files I want.<br>
(i.e. I get the folder Users, which contains my user_id folder, which contains AppData...).</p>

<p>Is there a way to add the files directly, without the folders, so that when I unzip, I get the files directly?  Thank you so much!</p>
