def is_zipfile(filename):
result = False<EOL>try:<EOL><INDENT>if hasattr(filename, "<STR_LIT>"):<EOL><INDENT>result = _check_zipfile(fp=filename)<EOL><DEDENT>else:<EOL><INDENT>with open(filename, "<STR_LIT:rb>") as fp:<EOL><INDENT>result = _check_zipfile(fp)<EOL><DEDENT><DEDENT><DEDENT>except IOError:<EOL><INDENT>pass<EOL><DEDENT>return result<EOL>
Quickly see if a file is a ZIP file by checking the magic number.

    The filename argument may be a file or file-like object too.