classification
Title: Documentation for email.charset confusing about the location of constants
Type: behavior Stage: needs patch
Components: Documentation Versions: Python 3.8, Python 3.7, Python 2.7
process
Status: open Resolution:
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, quantum.omega, r.david.murray
Priority: normal Keywords:

Created on 2018-05-09 17:38 by Francois Labelle, last changed 2018-05-10 21:17 by r.david.murray.

Messages (4)
msg316327 - (view) Author: Francois Labelle (Francois Labelle) Date: 2018-05-09 17:38
When mentioning the constants contained in the module email.charset, the documentation prefixes them with "Charset", for example: Charset.QP, Charset.BASE64, Charset.SHORTEST. This suggests that the constants can be found on the class "Charset" (uppercase first letter) in the module, while they are in fact contained in the the "charset" (lowercase first letter) module itself.

This is probably a left-over from when the module was called email.Charset (in 2.2 I believe). Under Python 2.7, while the documentation uses the same nomenclature, at least the module is also importable under the name email.Charset so it makes more sense.
msg316364 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-05-10 14:06
Can you provide an example of where this occurs in the docs?
msg316374 - (view) Author: Francois Labelle (quantum.omega) Date: 2018-05-10 20:20
Original poster here (OpenID just wouldn't work anymore).

For instance: https://docs.python.org/2/library/email.charset.html

Under "class email.charset.Charset"

Under "header_encoding"

"If the character set must be encoded before it can be used in an email header, this attribute will be set to Charset.QP (for quoted-printable), Charset.BASE64 (for base64 encoding), or Charset.SHORTEST for the shortest of QP or BASE64 encoding. Otherwise, it will be None."
msg316378 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2018-05-10 21:17
Ah, I see.  Yes, those strings are actually hardcoded in the documentation source instead of being references.  You are correct, they should be fixed.  Note, however, that Charset is part of the legacy API and isn't actually used if you use the new API in python3.
History
Date User Action Args
2018-05-10 21:17:45r.david.murraysettype: enhancement -> behavior
stage: needs patch
messages: + msg316378
versions: - Python 3.4, Python 3.5, Python 3.6
2018-05-10 20:20:07quantum.omegasetnosy: + quantum.omega, - Francois Labelle
messages: + msg316374
2018-05-10 14:06:37r.david.murraysetnosy: + r.david.murray
messages: + msg316364
2018-05-09 17:38:58Francois Labellecreate