def zipadd(func, zip_file, name):
 with tempfile.NamedTemporaryFile('wb', delete=False) as temp_file:
  func(temp_file)
  temp_file.close()
  zip_file.write(temp_file.name, arcname=name)
 if os.path.isfile(temp_file.name):
  os.remove(temp_file.name)

def zipadd ( func , zip_file , name ) : with tempfile . NamedTemporaryFile ( 'wb' , delete = False ) as temp_file : func ( temp_file ) temp_file . close ( ) zip_file . write ( temp_file . name , arcname = name ) if os . path . isfile ( temp_file . name ) : os . remove ( temp_file . name )
calls a function with a file object .