Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9b49133

Browse files
authored
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 32e8f9b)
1 parent 3ab24bd commit 9b49133

File tree

1 file changed

+5
-6
lines changed

1 file changed

+5
-6
lines changed

Doc/tutorial/controlflow.rst

+5-6
Original file line numberDiff line numberDiff line change
@@ -492,8 +492,7 @@ function like this::
492492
for arg in arguments:
493493
print(arg)
494494
print("-" * 40)
495-
keys = sorted(keywords.keys())
496-
for kw in keys:
495+
for kw in keywords:
497496
print(kw, ":", keywords[kw])
498497

499498
It could be called like this::
@@ -513,13 +512,13 @@ and of course it would print:
513512
It's very runny, sir.
514513
It's really very, VERY runny, sir.
515514
----------------------------------------
516-
client : John Cleese
517515
shopkeeper : Michael Palin
516+
client : John Cleese
518517
sketch : Cheese Shop Sketch
519518
520-
Note that the list of keyword argument names is created by sorting the result
521-
of the keywords dictionary's ``keys()`` method before printing its contents;
522-
if this is not done, the order in which the arguments are printed is undefined.
519+
Note that the order in which the keyword arguments are printed is guaranteed
520+
to match the order in which they were provided in the function call.
521+
523522

524523
.. _tut-arbitraryargs:
525524

0 commit comments

Comments
 (0)