I am trying to get the compressed size of a file with Python and zipfile
JavaScript
x
6
1
zip = zipfile.ZipFile('test.zip')
2
namelist = zip.namelist()
3
for fn in namelist:
4
print fn
5
print zip.getinfo(fn).compress_size()
6
I get the error
JavaScript
1
2
1
TypeError: 'int' object is not callable
2
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
JavaScript
1
2
1
print zip.getinfo(fn).compress_size
2
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.