I am trying to get the compressed size of a file with Python and zipfile
zip = zipfile.ZipFile('test.zip') namelist = zip.namelist() for fn in namelist: print fn print zip.getinfo(fn).compress_size()
I get the error
TypeError: 'int' object is not callable
What is the reason for that?
Advertisement
Answer
ZipInfo.compress_size is a simple int
attribute, not a method, so you just need to do
print zip.getinfo(fn).compress_size
BTW, it’s a Bad Idea to use zip
as the name of a variable, as it’s the name of a built-in function.