def GetZipWith(fname, content): fp = StringIO.StringIO() zf = zipfile.ZipFile(fp, "a", zipfile.ZIP_DEFLATED, False) zf.writestr(fname, content) zf.close() return fp.getvalue()