def outf_writer_compat(outfile, encoding, errors, gzip_compress=False):
 if compat.PY3:
  if gzip_compress:
   outf = gzip.open(outfile, 'wt', encoding=encoding, errors=errors)
  else:
   outf = open(outfile, 'w', encoding=encoding, errors=errors)
  writer = csv.writer(outf)
 else:
  if gzip_compress:
   outf = gzip.open(outfile, 'wb')
  else:
   outf = open(outfile, 'wb')
  writer = compat.UnicodeWriter(outf, encoding=encoding, errors=errors)
 return (writer, outf)

def outf_writer_compat ( outfile , encoding , errors , gzip_compress = False ) : if compat . PY3 : if gzip_compress : outf = gzip . open ( outfile , 'wt' , encoding = encoding , errors = errors ) else : outf = open ( outfile , 'w' , encoding = encoding , errors = errors ) writer = csv . writer ( outf ) else : if gzip_compress : outf = gzip . open ( outfile , 'wb' ) else : outf = open ( outfile , 'wb' ) writer = compat . UnicodeWriter ( outf , encoding = encoding , errors = errors ) return ( writer , outf )
identify appropriate csv writer given the python version .