[Tutor] reading comments

Kent Johnson kent37 at tds.net
Sat May 28 18:17:46 CEST 2005


Servando Garcia wrote:
> Hello list
> 		How do I read the comments attached to a zipfile or for any file .?

For a zipfile, you can open the file with the zipfile module. Each file in the zip has a ZipInfo 
object associated with it. You get a single ZipInfo using getinfo(name) on the opened ZipFile, or 
get a list of all ZipInfos with infolist().

  >>> import zipfile
  >>> zip = zipfile.ZipFile('myfile.zip')
  >>> i = zip.getinfo('afile.txt')
  >>> i.comment
'*'

Kent



More information about the Tutor mailing list