def GzipEncode(s):
 with closing(StringIO()) as sio:
  with gzip.GzipFile(fileobj=sio, mode='wb') as gzfile:
   gzfile.write(escape.utf8(s))
  return sio.getvalue()

def GzipEncode ( s ) : with closing ( StringIO ( ) ) as sio : with gzip . GzipFile ( fileobj = sio , mode = 'wb' ) as gzfile : gzfile . write ( escape . utf8 ( s ) ) return sio . getvalue ( )
compresses s with gzip and returns the result .