mirror of https://github.com/python/cpython.git
#16206: Improve examples about dict construction.
This commit is contained in:
parent
c131b0760d
commit
a20879ffc8
|
@ -2137,13 +2137,13 @@ pairs within braces, for example: ``{'jack': 4098, 'sjoerd': 4127}`` or ``{4098:
|
||||||
replaces the value from the positional argument.
|
replaces the value from the positional argument.
|
||||||
|
|
||||||
To illustrate, the following examples all return a dictionary equal to
|
To illustrate, the following examples all return a dictionary equal to
|
||||||
``{"one": 1, "two": 2}``::
|
``{"one": 1, "two": 2, "three": 3}``::
|
||||||
|
|
||||||
>>> a = dict(one=1, two=2)
|
>>> a = dict(one=1, two=2, three=3)
|
||||||
>>> b = dict({'one': 1, 'two': 2})
|
>>> b = {'one': 1, 'two': 2, 'three': 3}
|
||||||
>>> c = dict(zip(('one', 'two'), (1, 2)))
|
>>> c = dict(zip(['one', 'two', 'three'], [1, 2, 3]))
|
||||||
>>> d = dict([['two', 2], ['one', 1]])
|
>>> d = dict([('two', 2), ('one', 1), ('three', 3)])
|
||||||
>>> e = {"one": 1, "two": 2}
|
>>> e = dict({'three': 3, 'one': 1, 'two': 2})
|
||||||
>>> a == b == c == d == e
|
>>> a == b == c == d == e
|
||||||
True
|
True
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue