Kaydet (Commit) 32e8f9bd authored tarafından Jim Fasarakis-Hilliard's avatar Jim Fasarakis-Hilliard Kaydeden (comit) Mariatta

bpo-29453: Remove reference to undefined dictionary ordering in Tutorial (GH-140)

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
üst 8fb1f6e0
......@@ -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:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment