docstr: Append a string to the MIME header.
  
  Optional charset, if given, should be a Charset instance or the name
  of a character set (which will be converted to a Charset instance).  A
  value of None (the default) means that the charset given in the
  constructor is used.
  
  s may be a byte string or a Unicode string.  If it is a byte string
  (i.e. isinstance(s, str) is true), then charset is the encoding of
  that byte string, and a UnicodeError will be raised if the string
  cannot be decoded with that charset.  If s is a Unicode string, then
  charset is a hint specifying the character set of the characters in
  the string.  In this case, when producing an RFC 2822 compliant header
  using RFC 2047 rules, the Unicode string will be encoded using the
  following charsets in order: us-ascii, the charset hint, utf-8.  The
  first character set not to provoke a UnicodeError is used.
  
  Optional `errors' is passed as the third argument to any unicode() or
  ustr.encode() call.
docstr_tok: ["Append","a","string","to","the","MIME","header",".","Optional","charset",",","if","given",",","should","be","a","Charset","instance","or","the","name","of","a","character","set","(","which","will","be","converted","to","a","Charset","instance",")",".","A","value","of","None","(","the","default",")","means","that","the","charset","given","in","the","constructor","is","used",".","s","may","be","a","byte","string","or","a","Unicode","string",".","If","it","is","a","byte","string","(","i.e",".","isinstance","(","s",",","str",")","is","true",")",",","then","charset","is","the","encoding","of","that","byte","string",",","and","a","UnicodeError","will","be","raised","if","the","string","can","not","be","decoded","with","that","charset",".","If","s","is","a","Unicode","string",",","then","charset","is","a","hint","specifying","the","character","set","of","the","characters","in","the","string",".","In","this","case",",","when","producing","an","RFC","2822","compliant","header","using","RFC","2047","rules",",","the","Unicode","string","will","be","encoded","using","the","following","charsets","in","order",":","us-ascii",",","the","charset","hint",",","utf-8",".","The","first","character","set","not","to","provoke","a","UnicodeError","is","used",".","Optional","`","errors","'","is","passed","as","the","third","argument","to","any","unicode","(",")","or","ustr.encode","(",")","call","."]
code: def append(self, s, charset=None, errors="strict"):
      """Append a string to the MIME header.
  
      Optional charset, if given, should be a Charset instance or the name
      of a character set (which will be converted to a Charset instance).  A
      value of None (the default) means that the charset given in the
      constructor is used.
  
      s may be a byte string or a Unicode string.  If it is a byte string
      (i.e. isinstance(s, str) is true), then charset is the encoding of
      that byte string, and a UnicodeError will be raised if the string
      cannot be decoded with that charset.  If s is a Unicode string, then
      charset is a hint specifying the character set of the characters in
      the string.  In this case, when producing an RFC 2822 compliant header
      using RFC 2047 rules, the Unicode string will be encoded using the
      following charsets in order: us-ascii, the charset hint, utf-8.  The
      first character set not to provoke a UnicodeError is used.
  
      Optional `errors' is passed as the third argument to any unicode() or
      ustr.encode() call.
      """
      if charset is None:
          charset = self._charset
      elif not isinstance(charset, Charset):
          charset = Charset(charset)
      # If the charset is our faux 8bit charset, leave the string unchanged
      if charset != "8bit":
          # We need to test that the string can be converted to unicode and
          # back to a byte string, given the input and output codecs of the
          # charset.
          if isinstance(s, str):
              # Possibly raise UnicodeError if the byte string can't be
              # converted to a unicode with the input codec of the charset.
              incodec = charset.input_codec or "us-ascii"
              ustr = unicode(s, incodec, errors)
              # Now make sure that the unicode could be converted back to a
              # byte string with the output codec, which may be different
              # than the iput coded.  Still, use the original byte string.
              outcodec = charset.output_codec or "us-ascii"
              ustr.encode(outcodec, errors)
          elif isinstance(s, unicode):
              # Now we have to be sure the unicode string can be converted
              # to a byte string with a reasonable output codec.  We want to
              # use the byte string in the chunk.
              for charset in USASCII, charset, UTF8:
                  try:
                      outcodec = charset.output_codec or "us-ascii"
                      s = s.encode(outcodec, errors)
                      break
                  except UnicodeError:
                      pass
              else:
                  assert False, "utf-8 conversion failed"
      self._chunks.append((s, charset))
  
imports: import re
  import binascii
  import email.quoprimime
  import email.base64mime
  from email.errors import HeaderParseError
  from email.charset import Charset
label_desc: Use image node_id 6 for calling the Header obj's underlying member method code with example usage: obj.append(s, charset, errors) without return types