[Tutor] Formatting zip module arguments correctly

Alan Gauld alan.gauld at btinternet.com
Mon Apr 6 01:37:47 CEST 2009


"Benjamin Serrato" <benjamin.serrato at gmail.com> wrote

> formatting of my zip arguments is incorrect. Since I am unsure how to
> communicate best so I will show the code, the error message, and what I
> believe is happening.

Thats pretty close to communicating the best way! :-)

> zip_command = zipfile.ZipFile(target, 'w').write(source)
>
> if os.system(zip_command) == 0:

I didn't think you needed to call os.system when using the zipfile module?
The module should do everything itself... But your error occurs on the
line above and it says:

>  File "C:\Python30\lib\io.py", line 615, in __init__
>    _fileio._FileIO.__init__(self, name, mode, closefd)
> IOError: [Errno 13] Permission denied: 'C:\\Documents and 
> Settings\\Benjamin
> Serrato\\My Documents\\python\\backup_list'

You don't have permission to write that file.
Now either you don't have the right permissions on the OS or the file
is locked by another program?

But it looks like this is the file you are passing to zipfile?
I thought the filename in the constructor was supposed to
be the actual zipfile name (ie the output!) not the file you
are trying to zip? But I'm no zipfile module expert so I may
be wrong there.

HTH,

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




More information about the Tutor mailing list