Boiler Plate Python: Difference between revisions

From Hive76 Wiki
Jump to navigationJump to search
No edit summary
No edit summary
Line 1: Line 1:
Boilerplace Python is a project of FarMcKon involving a few Hive76 members.  The goal is to put out a small python tool in 20-50 lines each week. You can get to most of the examples at [[Far's Website | http://www.farmckon.net/?cat=16]]
Boilerplace Python is a project of FarMcKon involving a few Hive76 members.  The goal is to put out a small python tool in 20-50 lines each week. You can get to most of the examples at [[http://www.farmckon.net/?cat=16 | Far's Website]]
= Zipping and Unzipping files =
= Zipping and Unzipping files =
Zipping data into a file:
Zipping data into a file:

Revision as of 23:00, 8 September 2009

Boilerplace Python is a project of FarMcKon involving a few Hive76 members. The goal is to put out a small python tool in 20-50 lines each week. You can get to most of the examples at [| Far's Website]

Zipping and Unzipping files

Zipping data into a file:

import zipfile
zipHandle = zipfile.ZipFile('archive.zip','w',zipfile.ZIP_DEFLATED
zipHandle.write('file_to_add.py')
zipHandle.close()
del zipHandle

Listing what's in a file:

import zipfile
zipHandle = zipfile.ZipFile('archive.zip','r')
filesInZip =  zipHandle.namelist():
for filename in filesInZip:
    print filename
zipHandle.close()
del zipHandle