for i in range(len(packet)): for j in range(i, len(packet)): try: foo = zlib.decompress(packet[i:j], -15) if len(foo) > len(longest[0]): longest = (foo, i, j) except: pass