This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Remove reference to undefined dictionary ordering in Tutorial
Type: Stage: resolved
Components: Documentation Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Mariatta Nosy List: Jim Fasarakis-Hilliard, Mariatta, docs@python, methane, r.david.murray, rhettinger, serhiy.storchaka, xiang.zhang
Priority: normal Keywords: patch

Created on 2017-02-05 15:17 by Jim Fasarakis-Hilliard, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
controlflowdiff.patch Jim Fasarakis-Hilliard, 2017-02-05 15:17 review
controlflowdiff2.patch Jim Fasarakis-Hilliard, 2017-02-05 16:41 review
Pull Requests
URL Status Linked Edit
PR 140 merged Jim Fasarakis-Hilliard, 2017-02-16 20:15
PR 208 merged Mariatta, 2017-02-21 06:25
Messages (20)
msg287048 - (view) Author: Jim Fasarakis-Hilliard (Jim Fasarakis-Hilliard) * Date: 2017-02-05 15:17
Removes `keys = sorted(keywords.keys())` from function example and removes the text that describes why this was necessary. As per PEP 468, this note is obsolete for 3.6+

Also changes the ordering of the function call to match the previous output.
msg287050 - (view) Author: Inada Naoki (methane) * (Python committer) Date: 2017-02-05 15:42
LGTM
msg287051 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-02-05 15:44
It is not (yet) a language requirement that ordinary dictionaries be ordered.  This patch may become appropriate in 3.7, but that has not yet been determined.  It is not appropriate for 3.6.  In 3.6, the order of keys in an ordinary dictionary is still undefined, even though it is in practice consistent in CPython.
msg287053 - (view) Author: Jim Fasarakis-Hilliard (Jim Fasarakis-Hilliard) * Date: 2017-02-05 15:56
Isn't it a language requirement that `**kwargs` be ordered in 3.6, David? 

PEP 468 states that `**kwargs` is to be an ordered *mapping* and, if I'm not mistaken, that was done in order to not depend on the fact that dicts became ordered. I might have understood something wrong, though :-)
msg287054 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2017-02-05 16:01
David, actually I have the same thoughts as Jim. Ordered ordinary dicts is not a feature but ordered **kwargs is in 3.6. They seems not the same thing.
msg287056 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-05 16:22
I would not change the order of keyword arguments, but rather change the output.
msg287057 - (view) Author: Jim Fasarakis-Hilliard (Jim Fasarakis-Hilliard) * Date: 2017-02-05 16:24
It was a random decision on my part, Serhiy, since I didn't see any difference. Why would you go the other way around?
msg287058 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-05 16:33
Because it shows preserving the order of keyword arguments (rather than sorting by keyword name).
msg287059 - (view) Author: Jim Fasarakis-Hilliard (Jim Fasarakis-Hilliard) * Date: 2017-02-05 16:41
Indeed, good point. Changed it to the suggested way.
msg287060 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-05 16:46
LGTM. Thanks Jim.

But maybe it is worth to mention that the output corresponds to the order of passed keyword arguments.
msg287061 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2017-02-05 19:21
You are correct, I didn't read the full context of the diff.  My apologies.
msg287092 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-02-06 07:36
Patch 2 looks fine to me.
msg287138 - (view) Author: Jim Fasarakis-Hilliard (Jim Fasarakis-Hilliard) * Date: 2017-02-06 14:27
> But maybe it is worth to mention that the output corresponds to the order of passed keyword arguments
 
Should I add this note? It looks fine to me as is but I'm not the experienced one here :-)
msg287219 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-02-07 09:33
I don't know. David, Raymond, what are your thoughts?
msg288047 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-02-18 01:11
>> But maybe it is worth to mention that the output 
>> corresponds to the order of passed keyword arguments
 
> Should I add this note? 

Yes, please.  This is a section on keyword arguments, making it the preferred place to mention the new guaranteed output order.
msg288081 - (view) Author: Jim Fasarakis-Hilliard (Jim Fasarakis-Hilliard) * Date: 2017-02-18 14:37
Added the following short sentence to the PR, which I believe makes the point clear: 

Note that the order in which the keyword arguments are printed is guaranteed to match the order in which they were provided in the function call.
msg288098 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2017-02-19 03:29
Thanks for the revision.  Assigning to Mariatta so that she can apply the PR.
msg288272 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-02-21 06:20
New changeset 32e8f9bdfd4324f1aa4fbbdf1ed8536f2b00cabb by Mariatta in branch 'master':
bpo-29453: Remove reference to undefined dictionary ordering in Tutorial (GH-140)
https://github.com/python/cpython/commit/32e8f9bdfd4324f1aa4fbbdf1ed8536f2b00cabb
msg288313 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-02-21 18:30
New changeset 9b49133082ec23b67e84d2589e66d7810018e424 by GitHub in branch '3.6':
bpo-29453: Remove reference to undefined dictionary ordering in Tutorial (GH-140) (#208)
https://github.com/python/cpython/commit/9b49133082ec23b67e84d2589e66d7810018e424
msg288314 - (view) Author: Mariatta (Mariatta) * (Python committer) Date: 2017-02-21 18:32
Thanks everyone. PR has been merged and backported to 3.6 :)
Closing this issue.
History
Date User Action Args
2022-04-11 14:58:42adminsetgithub: 73639
2017-02-21 18:32:35Mariattasetstatus: open -> closed
resolution: fixed
messages: + msg288314

stage: commit review -> resolved
2017-02-21 18:30:10Mariattasetmessages: + msg288313
2017-02-21 06:25:03Mariattasetpull_requests: + pull_request177
2017-02-21 06:20:26Mariattasetmessages: + msg288272
2017-02-19 03:29:38rhettingersetassignee: serhiy.storchaka -> Mariatta

messages: + msg288098
nosy: + Mariatta
2017-02-18 14:37:55Jim Fasarakis-Hilliardsetmessages: + msg288081
2017-02-18 01:12:00rhettingersetmessages: + msg288047
2017-02-16 20:15:52Jim Fasarakis-Hilliardsetpull_requests: + pull_request100
2017-02-07 09:33:55serhiy.storchakasetmessages: + msg287219
2017-02-06 14:27:57Jim Fasarakis-Hilliardsetmessages: + msg287138
2017-02-06 07:36:02rhettingersetnosy: + rhettinger
messages: + msg287092
2017-02-06 02:30:05xiang.zhangsetassignee: docs@python -> serhiy.storchaka
2017-02-05 19:21:01r.david.murraysetmessages: + msg287061
versions: + Python 3.6
2017-02-05 16:46:42serhiy.storchakasetmessages: + msg287060
stage: commit review
2017-02-05 16:41:05Jim Fasarakis-Hilliardsetfiles: + controlflowdiff2.patch

messages: + msg287059
2017-02-05 16:33:22serhiy.storchakasetmessages: + msg287058
2017-02-05 16:24:48Jim Fasarakis-Hilliardsetmessages: + msg287057
2017-02-05 16:22:18serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg287056
2017-02-05 16:01:55xiang.zhangsetmessages: + msg287054
2017-02-05 15:56:37Jim Fasarakis-Hilliardsetmessages: + msg287053
2017-02-05 15:44:32r.david.murraysetnosy: + r.david.murray

messages: + msg287051
versions: - Python 3.6
2017-02-05 15:42:37methanesetnosy: + methane
messages: + msg287050
2017-02-05 15:28:28xiang.zhangsetnosy: + xiang.zhang
2017-02-05 15:17:27Jim Fasarakis-Hilliardcreate