[Tutor] Zip Command

Alan Gauld alan.gauld at btinternet.com
Thu Oct 14 10:51:16 CEST 2010


<delegbede at dudupay.com> wrote

> Back to the module for zip, do I have to import it into my code for 
> use?
> It actually works on two lists as you rightly said.

zip is a command so does not need to be imported,
but it does not do what you want. You need the zipfile module
which does need to be imported.

> I am supposed to create a back up files from 2 directories
> into another seperate directory on my PC and I want the
> backup wrapped in a zip folder.

What you are calling a zip folder is in fact a zip file, it just so 
happens
that Windows displays it as a folder in explorer. So if you use the
zipfile module you can create a zip file from the contents of your 
folders.

But using zipfile will require you to read the documentation 
carefully.

OK I found the Byte of Python pages you are reading.
This uses the ziip command from the OS not the Python zip command
so it's a different issue. There are numerous zip utilities you can 
use
on Windows but you will need to download them and install them.

Some options include

winzip - shareware
gzip - aka gunzip GNU opensource version - probably your best bet.

You will need to change the commandline from the one in the book
to match the tool you choose.

HTH,

-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list