Why zipfile module is_zipfile function cannot detech a gzip file?
Question: I am aware of this question [Why "is_zipfile" function of module "zipfile"
always returns "false"?](http://stackoverflow.com/questions/14174048/why-is-
zipfile-function-of-module-zipfile-always-returns-false). I want to seek some
more clarification and confirmation.

I have created a zip file in python using the gzip module.

If I check the zip file using the `file` command in OSX I get this

    
    
    >  file data.txt
    data.txt: gzip compressed data, was "Slide1.html", last modified: Tue Oct 13 10:10:13 2015, max compression
    

I want to write a generic function to tell if the file is gzip'ed or not.

    
    
    import gzip
    import os
    
    f = '/path/to/data.txt'
    print os.path.exists(f)  # True
    
    with gzip.GzipFile(f) as zf:  
        print zf.read()  # Print out content as expected
    
    import zipfile
    
    print zipfile.is_zipfile(f)  # Give me false.  Not expected
    

I want to use `zipfile` module but it always reports false.

I just want to have a confirmation that `zipfile` module is not compatible
with `gzip`. If so, why it is the case? Are `zip` and `gzip` considered
different format?


Answer: > I have created a zip file in python using the gzip module.

No you haven't. gzip doesn't create zip files.

> I just want to have a confirmation that zipfile module is not compatible
> with gzip.

Confirmed.

> If so, why it is the case?

A gzip file is a single file compressed with zlib with a very small header. A
zip file is multiple files, each optionally compressed with zlib, in a single
archive with a header and directory.

> Are zip and gzip considered different format?

Yes.

