Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Python Programming Language

zipfile: grabbing whole directories


> The built in zipfile.write doesn't seem to like  taking a directory instead
> of  a filename.

> for example:
> for each in listofdir:
>                 archive.write(each)

> blows up when one of the items listed in listofdir is a subdirectory.

>   File "/usr/local/lib/python2.4/zipfile.py", line 405, in write
>     fp = open(filename, "rb")

> is there a mode or a '-r' style param I am missing?

I guess what you really want is recursively archive every file in a
directory and its subdirectories. If that is the case you can use
os.walk to iterate over all such files so you can archive all of them
while the directory structure will be preserved.

HTH,
Daniel

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc