[issue29453] Remove reference to undefined dictionary ordering in Tutorial
New submission from Jim Fasarakis-Hilliard:
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.
----------
assignee: docs@python
components: Documentation
files: controlflowdiff.patch
keywords: patch
messages: 287048
nosy: Jim Fasarakis-Hilliard, docs@python
priority: normal
severity: normal
status: open
title: Remove reference to undefined dictionary ordering in Tutorial
versions: Python 3.6, Python 3.7
Added file: http://bugs.python.org/file46524/controlflowdiff.patch
_______________________________________
Python tracker
Changes by Xiang Zhang
INADA Naoki added the comment:
LGTM
----------
nosy: +inada.naoki
_______________________________________
Python tracker
R. David Murray added the comment:
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.
----------
nosy: +r.david.murray
versions: -Python 3.6
_______________________________________
Python tracker
Jim Fasarakis-Hilliard added the comment:
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 :-)
----------
_______________________________________
Python tracker
Xiang Zhang added the comment:
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.
----------
_______________________________________
Python tracker
Serhiy Storchaka added the comment:
I would not change the order of keyword arguments, but rather change the output.
----------
nosy: +serhiy.storchaka
_______________________________________
Python tracker
Jim Fasarakis-Hilliard added the comment:
It was a random decision on my part, Serhiy, since I didn't see any difference. Why would you go the other way around?
----------
_______________________________________
Python tracker
Serhiy Storchaka added the comment:
Because it shows preserving the order of keyword arguments (rather than sorting by keyword name).
----------
_______________________________________
Python tracker
Jim Fasarakis-Hilliard added the comment:
Indeed, good point. Changed it to the suggested way.
----------
Added file: http://bugs.python.org/file46525/controlflowdiff2.patch
_______________________________________
Python tracker
Serhiy Storchaka added the comment:
LGTM. Thanks Jim.
But maybe it is worth to mention that the output corresponds to the order of passed keyword arguments.
----------
stage: -> commit review
_______________________________________
Python tracker
R. David Murray added the comment:
You are correct, I didn't read the full context of the diff. My apologies.
----------
versions: +Python 3.6
_______________________________________
Python tracker
Changes by Xiang Zhang
Raymond Hettinger added the comment:
Patch 2 looks fine to me.
----------
nosy: +rhettinger
_______________________________________
Python tracker
Jim Fasarakis-Hilliard added the comment:
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 :-)
----------
_______________________________________
Python tracker
Serhiy Storchaka added the comment:
I don't know. David, Raymond, what are your thoughts?
----------
_______________________________________
Python tracker
Changes by Jim Fasarakis-Hilliard
Raymond Hettinger added the comment:
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.
----------
_______________________________________
Python tracker
Jim Fasarakis-Hilliard added the comment:
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.
----------
_______________________________________
Python tracker
Raymond Hettinger added the comment:
Thanks for the revision. Assigning to Mariatta so that she can apply the PR.
----------
assignee: serhiy.storchaka -> Mariatta
nosy: +Mariatta
_______________________________________
Python tracker
Mariatta Wijaya added the comment:
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/32e8f9bdfd4324f1aa4fbbdf1ed8536f2b0...
----------
_______________________________________
Python tracker
Changes by Mariatta Wijaya
Mariatta Wijaya added the comment:
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/9b49133082ec23b67e84d2589e66d781001...
----------
_______________________________________
Python tracker
Mariatta Wijaya added the comment:
Thanks everyone. PR has been merged and backported to 3.6 :)
Closing this issue.
----------
resolution: -> fixed
stage: commit review -> resolved
status: open -> closed
_______________________________________
Python tracker
participants (7)
-
INADA Naoki
-
Jim Fasarakis-Hilliard
-
Mariatta Wijaya
-
R. David Murray
-
Raymond Hettinger
-
Serhiy Storchaka
-
Xiang Zhang