diff options
Diffstat (limited to 'Doc/library/email.header.rst')
-rw-r--r-- | Doc/library/email.header.rst | 74 |
1 files changed, 38 insertions, 36 deletions
diff --git a/Doc/library/email.header.rst b/Doc/library/email.header.rst index 0ecd35f..000d48e 100644 --- a/Doc/library/email.header.rst +++ b/Doc/library/email.header.rst @@ -76,65 +76,67 @@ Here is the :class:`Header` class description: and is usually either a space or a hard tab character. This character will be prepended to continuation lines. -Optional *errors* is passed straight through to the :meth:`append` method. + Optional *errors* is passed straight through to the :meth:`append` method. -.. method:: Header.append(s[, charset[, errors]]) + .. method:: append(s[, charset[, errors]]) - Append the string *s* to the MIME header. + Append the string *s* to the MIME header. - Optional *charset*, if given, should be a :class:`Charset` instance (see - :mod:`email.charset`) or the name of a character set, which will be converted to - a :class:`Charset` instance. A value of ``None`` (the default) means that the - *charset* given in the constructor is used. + Optional *charset*, if given, should be a :class:`Charset` instance (see + :mod:`email.charset`) or the name of a character set, which will be + converted to a :class:`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 :exc:`UnicodeError` will be raised if the string cannot be decoded - with that character set. + *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 :exc:`UnicodeError` will be raised if the string + cannot be decoded with that character set. - 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 to not provoke a :exc:`UnicodeError` - is used. + 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 to + not provoke a :exc:`UnicodeError` is used. - Optional *errors* is passed through to any :func:`unicode` or - :func:`ustr.encode` call, and defaults to "strict". + Optional *errors* is passed through to any :func:`unicode` or + :func:`ustr.encode` call, and defaults to "strict". -.. method:: Header.encode([splitchars]) + .. method:: encode([splitchars]) - Encode a message header into an RFC-compliant format, possibly wrapping long - lines and encapsulating non-ASCII parts in base64 or quoted-printable encodings. - Optional *splitchars* is a string containing characters to split long ASCII - lines on, in rough support of :rfc:`2822`'s *highest level syntactic breaks*. - This doesn't affect :rfc:`2047` encoded lines. + Encode a message header into an RFC-compliant format, possibly wrapping + long lines and encapsulating non-ASCII parts in base64 or quoted-printable + encodings. Optional *splitchars* is a string containing characters to + split long ASCII lines on, in rough support of :rfc:`2822`'s *highest + level syntactic breaks*. This doesn't affect :rfc:`2047` encoded lines. -The :class:`Header` class also provides a number of methods to support standard -operators and built-in functions. + The :class:`Header` class also provides a number of methods to support + standard operators and built-in functions. -.. method:: Header.__str__() + .. method:: __str__() - A synonym for :meth:`Header.encode`. Useful for ``str(aHeader)``. + A synonym for :meth:`Header.encode`. Useful for ``str(aHeader)``. -.. method:: Header.__unicode__() + .. method:: __unicode__() - A helper for the built-in :func:`unicode` function. Returns the header as a - Unicode string. + A helper for the built-in :func:`unicode` function. Returns the header as + a Unicode string. -.. method:: Header.__eq__(other) + .. method:: __eq__(other) - This method allows you to compare two :class:`Header` instances for equality. + This method allows you to compare two :class:`Header` instances for + equality. -.. method:: Header.__ne__(other) + .. method:: __ne__(other) - This method allows you to compare two :class:`Header` instances for inequality. + This method allows you to compare two :class:`Header` instances for + inequality. The :mod:`email.header` module also provides the following convenient functions. |