You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
doctest: Change example under warnings section #79020
The Warnings section of the doctest documentation (https://docs.python.org/3.8/library/doctest.html#warnings) contains an example that the printing order of a dictionary is not guaranteed. Since it is now guaranteed to be insertion order, perhaps the example should be changed.
To me, the question is whether to delete the dict example, or qualify it with "Before 3.7 (or 3.6 for CPython)" but leave the illustration of workarounds. Raymond, what do you thing?
Add a comment along the lines you (Terry) suggested. Some people need to write doctests that run under many versions of Python, so the info is still supremely relevant to them.
You say we need to keep this illustration with a section 'before 3.6' but in think it's a bad thing.
when you read a documentation, you just copy the example, and sometimes you don't read the requirements.
why do we need to keep an illustration for a previous version of Python? since >= 3.6 we keep the order (officially in 3.7), in this case, the example is useless, because you read the documentation of >= 3.7.
I would prefer to remove this example for >= 3.6 and keep the illustration for the previous version.
I am really interested by the feedback of Tim, Cheryl and Raymond.
Stephane, it's not deep. People who need to write doctests that work across N versions of Python shouldn't need to read N versions of the documentation. This is hardly unique to doctest. We routinely add "Changed in version m.n" blurbs all over the place.
Ways that were _necessary_ for robust dict testing continue to work fine in 3.6 and 3.7, so it doesn't harm anything if people mindlessly copy an example that _could_ be spelled some other way under 3.6+. It's not like there's even anything slightly obscure about, e.g.,
I understand. It's just my experience, I have seen a lot of new comers (in my python trainings), they just copy the examples and don't read the total explanation. sometimes, because english is not their native language and in this case, they try to find an example, copy/paste and run it and when there is an exception, they will try to read the doc.
so, I have pushed a PR, I just changed sentences, I am waiting for your suggestions.
New changeset 0522fd8 by Julien Palard (Stéphane Wirtel) in branch 'master': bpo-34839: Add a 'before 3.6' in the section 'warnings' of doctest (GH-9736) 0522fd8
Activity
csabella commentedon Sep 29, 2018
The Warnings section of the doctest documentation (https://docs.python.org/3.8/library/doctest.html#warnings) contains an example that the printing order of a dictionary is not guaranteed. Since it is now guaranteed to be insertion order, perhaps the example should be changed.
terryjreedy commentedon Oct 5, 2018
To me, the question is whether to delete the dict example, or qualify it with "Before 3.7 (or 3.6 for CPython)" but leave the illustration of workarounds. Raymond, what do you thing?
tim-one commentedon Oct 5, 2018
Add a comment along the lines you (Terry) suggested. Some people need to write doctests that run under many versions of Python, so the info is still supremely relevant to them.
csabella commentedon Oct 5, 2018
Thanks for the discussion. I'll mark this as 'easy' for a first-time contribution.
terryjreedy commentedon Oct 5, 2018
I am posting this on core-mentorship. If you want to do this, post here and submit the PR within a day. I will do the merge is no-one else does.
lysnikolaou commentedon Oct 5, 2018
I would be happy to change this. I will submit a PR ASAP.
matrixise commentedon Oct 6, 2018
Hi Terry,
You say we need to keep this illustration with a section 'before 3.6' but in think it's a bad thing.
I would prefer to remove this example for >= 3.6 and keep the illustration for the previous version.
I am really interested by the feedback of Tim, Cheryl and Raymond.
rhettinger commentedon Oct 6, 2018
I concur with Tim.
rhettinger commentedon Oct 6, 2018
FWIW, set objects are still unordered, so they too require sorting for a reproducible doctest.
matrixise commentedon Oct 6, 2018
Hi Raymond,
Ok, if you agree with Tim, I just created a PR.
Have a nice day,
tim-one commentedon Oct 6, 2018
Stephane, it's not deep. People who need to write doctests that work across N versions of Python shouldn't need to read N versions of the documentation. This is hardly unique to doctest. We routinely add "Changed in version m.n" blurbs all over the place.
Ways that were _necessary_ for robust dict testing continue to work fine in 3.6 and 3.7, so it doesn't harm anything if people mindlessly copy an example that _could_ be spelled some other way under 3.6+. It's not like there's even anything slightly obscure about, e.g.,
matrixise commentedon Oct 6, 2018
Tim,
I understand. It's just my experience, I have seen a lot of new comers (in my python trainings), they just copy the examples and don't read the total explanation. sometimes, because english is not their native language and in this case, they try to find an example, copy/paste and run it and when there is an exception, they will try to read the doc.
so, I have pushed a PR, I just changed sentences, I am waiting for your suggestions.
Thank you for your explanation.
matrixise commentedon Oct 10, 2018
Hi Raymond and Tim,
I just updated the PR with your recommendations.
Have a nice day,
JulienPalard commentedon Oct 20, 2018
New changeset 0522fd8 by Julien Palard (Stéphane Wirtel) in branch 'master':
bpo-34839: Add a 'before 3.6' in the section 'warnings' of doctest (GH-9736)
0522fd8
miss-islington commentedon Apr 12, 2019
New changeset a910c2c by Miss Islington (bot) in branch '3.7':
bpo-34839: Add a 'before 3.6' in the section 'warnings' of doctest (GH-9736)
a910c2c