code: def join_header_words(lists):
      
      headers = []
      for pairs in lists:
          attr = []
          for k, v in pairs:
              if v is not None:
                  if not re.search(r"^\w+$", v):
                      v = HEADER_JOIN_ESCAPE_RE.sub(r"\\\1", v)  # escape " and \
                      v = '"%s"' % v
                  k = "%s=%s" % (k, v)
              attr.append(k)
          if attr: headers.append("; ".join(attr))
      return ", ".join(headers)
docs: Do the inverse (almost) of the conversion done by split_header_words.
  
      Takes a list of lists of (key, value) pairs and produces a single header
      value.  Attribute values are quoted if needed.
  
      >>> join_header_words([[("text/plain", None), ("charset", "iso-8859/1")]])
      'text/plain; charset="iso-8859/1"'
      >>> join_header_words([[("text/plain", None)], [("charset", "iso-8859/1")]])
      'text/plain, charset="iso-8859/1"'