diff options
author | Mariatta <Mariatta@users.noreply.github.com> | 2017-02-21 18:30:07 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-21 18:30:07 (GMT) |
commit | 9b49133082ec23b67e84d2589e66d7810018e424 (patch) | |
tree | 1b54dd651ef46fb0d73afe8f635c1e81b1f6981a /Doc/tutorial | |
parent | 3ab24bdd47fdd9d45719ad49f93d3878d4442d7e (diff) | |
download | cpython-9b49133082ec23b67e84d2589e66d7810018e424.zip cpython-9b49133082ec23b67e84d2589e66d7810018e424.tar.gz cpython-9b49133082ec23b67e84d2589e66d7810018e424.tar.bz2 |
bpo-29453: Remove reference to undefined dictionary ordering in Tutorial (GH-140) (#208)
As of Python 3.6 **kwargs are ordered, thus, remove the paragraph stating that
ordering is undefined and change snippet to remove the unecessary sorted call.
* Add sentence mentioning guaranteed output order of kwargs
(cherry picked from commit 32e8f9bdfd4324f1aa4fbbdf1ed8536f2b00cabb)
Diffstat (limited to 'Doc/tutorial')
-rw-r--r-- | Doc/tutorial/controlflow.rst | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/Doc/tutorial/controlflow.rst b/Doc/tutorial/controlflow.rst index d434618..6a9bb48 100644 --- a/Doc/tutorial/controlflow.rst +++ b/Doc/tutorial/controlflow.rst @@ -492,8 +492,7 @@ function like this:: for arg in arguments: print(arg) print("-" * 40) - keys = sorted(keywords.keys()) - for kw in keys: + for kw in keywords: print(kw, ":", keywords[kw]) It could be called like this:: @@ -513,13 +512,13 @@ and of course it would print: It's very runny, sir. It's really very, VERY runny, sir. ---------------------------------------- - client : John Cleese shopkeeper : Michael Palin + client : John Cleese sketch : Cheese Shop Sketch -Note that the list of keyword argument names is created by sorting the result -of the keywords dictionary's ``keys()`` method before printing its contents; -if this is not done, the order in which the arguments are printed is undefined. +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. + .. _tut-arbitraryargs: |