mirror of
https://github.com/python/cpython.git
synced 2025-09-30 12:21:51 +00:00
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 32e8f9bdfd
)
This commit is contained in:
parent
3ab24bdd47
commit
9b49133082
1 changed files with 5 additions and 6 deletions
|
@ -492,8 +492,7 @@ function like this::
|
||||||
for arg in arguments:
|
for arg in arguments:
|
||||||
print(arg)
|
print(arg)
|
||||||
print("-" * 40)
|
print("-" * 40)
|
||||||
keys = sorted(keywords.keys())
|
for kw in keywords:
|
||||||
for kw in keys:
|
|
||||||
print(kw, ":", keywords[kw])
|
print(kw, ":", keywords[kw])
|
||||||
|
|
||||||
It could be called like this::
|
It could be called like this::
|
||||||
|
@ -513,13 +512,13 @@ and of course it would print:
|
||||||
It's very runny, sir.
|
It's very runny, sir.
|
||||||
It's really very, VERY runny, sir.
|
It's really very, VERY runny, sir.
|
||||||
----------------------------------------
|
----------------------------------------
|
||||||
client : John Cleese
|
|
||||||
shopkeeper : Michael Palin
|
shopkeeper : Michael Palin
|
||||||
|
client : John Cleese
|
||||||
sketch : Cheese Shop Sketch
|
sketch : Cheese Shop Sketch
|
||||||
|
|
||||||
Note that the list of keyword argument names is created by sorting the result
|
Note that the order in which the keyword arguments are printed is guaranteed
|
||||||
of the keywords dictionary's ``keys()`` method before printing its contents;
|
to match the order in which they were provided in the function call.
|
||||||
if this is not done, the order in which the arguments are printed is undefined.
|
|
||||||
|
|
||||||
.. _tut-arbitraryargs:
|
.. _tut-arbitraryargs:
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue