Adding to a zip file
Peter Hansen
peter at engcorp.com
Wed Jul 28 06:47:49 EDT 2004
Dennis Hotson wrote:
> I'm having trouble adding a file to a .zip file using python2.3.
> The write method of a ZipFile object needs a filename in
> order to add a file to the archive.
>
> The problem is that I want to add a 'file-like' object... ie the 'file'
> doesn't have a real filename.
>
> Any suggestions on what I could do? :)
Look for the writestr() method of the ZipFile object.
> Oh and also, I looked at os.tmpname() to try and create a temporary
> file.. but I keep getting warnings about it's security. Does anyone know
> how safe it would be to use it?
Exactly as safe as the docs suggest? In any case, I would
suggest looking at the "tempfile" module instead.
-Peter
More information about the Python-list
mailing list