def zlib_compress(data):
    """
    Compress things in a py2/3 safe fashion
    >>> json_str = '{"test": 1}'
    >>> blob = zlib_compress(json_str)
    """
    if PY3K:
        if isinstance(data, str):
            return zlib.compress(bytes(data, 'utf-8'))
        return zlib.compress(data)
    return zlib.compress(data)
def zlib_compress ( data ) : if PY3K : if isinstance ( data , str ) : return zlib . compress ( bytes ( data , 'utf-8' ) ) return zlib . compress ( data ) return zlib . compress ( data )
Compress things in a py2/3 safe fashion
    >>> json_str = '{"test": 1}'
    >>> blob = zlib_compress(json_str)