-
-
Notifications
You must be signed in to change notification settings - Fork 31.9k
Make description of presentation types f
and e
in format spec more clear
#123133
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
I am not a native speaker of English, but for me it's pretty obvious from first two sentences, that "no digits follow the decimal point" case might correspond only to precision=0. "No precision given" means precision=6. Text seems very clear. Where is the source of confusion? |
I though that case "If no digits follow the decimal point" is a subcase for "With no precision given". For example, |
The current description has the following structure: given precision -> no given precision -> specific given description. It would be more logical to not separate cases with given precision. I propose such structure: given precision -> specific given precision -> no given precision. Such structure is already present in the description of |
You just ignored the first sentence. One told you that number of digits after the point is equal to precision.
Rather: full description of the precision setting (with defaults, 2nd sentence). Then specific behaviour for precision=0. I don't see what we gain, if discussion of defaults for precision will be the last sentence. |
CC @picnixz |
I think I understand why there is a confusion. When we say "no digits follow the decimal point", we may think of "no digits follow the decimal point in the number being formatted" independently of the precision itself. For instance, you could expect While the meaning is clear and without ambiguities if you take your time to read the entire text, I agree that it might be confusing to some people, especially if this is something that beginners could stumble upon. What we can however say is: "If p = 0 and no digits follow the decimal point, then [...], unless |
That's from the last sentence from the paragraph. It looks rather strange for me to interpret text from the end... But first two sentences clearly show 1) how many digits could be in the fractional part (exactly
I think there is no doubts, if you read 1) the whole text and 2) in the correct order. But I would appreciate opinion of docs experts. |
Thanks @picnixz for the summary and @skirpichev for asking for feedback from experts. #111125 (comment) @serhiy-storchaka's example clarifies the behavior well, and it likely makes sense to add this for clarity. It could go in the "Example section" that follows the table. Another alternative improvement would be to split the text into more than one paragraph. Current text:
Modified text (changes in bold font):
@Prometheus3375 Would this modified text clarify the behavior for you? |
I suggest to write "If p=0, the decimal point is omitted unless the # option is used." or "If p=0, the decimal point is only added if the # option is used." or "The decimal point is omitted if p=0 and the # option is not used." Or something like. |
@willingc the source of my confusion is phrase "If no digits follow the decimal point". Because what actually meant here is "If no digits follow the decimal point in the result of formatting", but I perceive this as "If no digits follow the decimal point in the number being formatted" or "If no digits follow the decimal point in the format string". I originally assumed the latter, but quick test had shown that this is an invalid format string, so I decided to try the former. In this issue I referred to the description of
Here it is clear that "if there are no remaining digits following it" refers to the moment after formatting is done by the provided context. Re-evaluating my suggestions I provided in the issue, I think that replacement of "If no digits follow the decimal point" with "If
The sentence "For a given precision p, formats the number as a decimal number with exactly p digits following the decimal point" defines |
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Ok, it seems OP is ok with Serhiy suggestion. I took liberty to make a small pr with this change: #125426 |
Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…ythonGH-125426) (cherry picked from commit cfc27bc) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
…ythonGH-125426) (cherry picked from commit cfc27bc) Co-authored-by: Sergey B Kirpichev <skirpichev@gmail.com> Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Closed by #125426. Thanks everyone for thoughtful discussion and a team effort to improve the description. ☀️ |
Some time ago I was reading docs of format specification mini-language and got a bit confused with the description for presentation type
f
. Because of my misunderstanding, I created #111125 thinking there is an error in docs. There I got an explanation what was actually meant.Here is the current description of type
f
:The source of my confusion had come from the last sentence. I assumed that it refers to the case with no precision given mentioned in the previous sentence, but it actually refers to the case when
p
is zero. For comparison, the description of typeg
at first lists the case when no digits follow the decimal point, and then in a different paragraph lists the case with no precision given (I do not quote the description here because it is too large).I suggest to rearrange two last sentences in descriptions of types
f
ande
and maybe rephrase some parts. Here are two examples for typef
.Just rearrangement:
Rearranged sentences with edited 2nd sentence.
Linked PRs
The text was updated successfully, but these errors were encountered: