Skip to content
Projeler
Gruplar
Parçacıklar
Yardım
Yükleniyor...
Oturum aç / Kaydol
Gezinmeyi değiştir
C
cpython
Proje
Proje
Ayrıntılar
Etkinlik
Cycle Analytics
Depo (repository)
Depo (repository)
Dosyalar
Kayıtlar (commit)
Dallar (branch)
Etiketler
Katkıda bulunanlar
Grafik
Karşılaştır
Grafikler
Konular (issue)
0
Konular (issue)
0
Liste
Pano
Etiketler
Kilometre Taşları
Birleştirme (merge) Talepleri
0
Birleştirme (merge) Talepleri
0
CI / CD
CI / CD
İş akışları (pipeline)
İşler
Zamanlamalar
Grafikler
Paketler
Paketler
Wiki
Wiki
Parçacıklar
Parçacıklar
Üyeler
Üyeler
Collapse sidebar
Close sidebar
Etkinlik
Grafik
Grafikler
Yeni bir konu (issue) oluştur
İşler
Kayıtlar (commit)
Konu (issue) Panoları
Kenar çubuğunu aç
Batuhan Osman TASKAYA
cpython
Commits
dfbbbf16
Kaydet (Commit)
dfbbbf16
authored
Nis 04, 2018
tarafından
hui shang
Kaydeden (comit)
INADA Naoki
Nis 04, 2018
Dosyalara gözat
Seçenekler
Dosyalara Gözat
İndir
Eposta Yamaları
Sade Fark
bpo-32337: Update documentats about dict order (GH-4973)
üst
c869529e
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
21 additions
and
23 deletions
+21
-23
stdtypes.rst
Doc/library/stdtypes.rst
+8
-8
datastructures.rst
Doc/tutorial/datastructures.rst
+11
-15
ACKS
Misc/ACKS
+1
-0
2017-12-22-17-29-37.bpo-32337.eZe-ID.rst
...xt/Documentation/2017-12-22-17-29-37.bpo-32337.eZe-ID.rst
+1
-0
No files found.
Doc/library/stdtypes.rst
Dosyayı görüntüle @
dfbbbf16
...
@@ -4256,17 +4256,17 @@ support membership tests:
...
@@ -4256,17 +4256,17 @@ support membership tests:
Return an iterator over the keys, values or items (represented as tuples of
Return an iterator over the keys, values or items (represented as tuples of
``(key, value)``) in the dictionary.
``(key, value)``) in the dictionary.
Keys and values are iterated over in an arbitrary order which is non-random,
Keys and values are iterated over in insertion order.
varies across Python implementations, and depends on the dictionary's history
This allows the creation of ``(value, key)`` pairs
of insertions and deletions. If keys, values and items views are iterated
over with no intervening modifications to the dictionary, the order of items
will directly correspond. This allows the creation of ``(value, key)`` pairs
using :func:`zip`: ``pairs = zip(d.values(), d.keys())``. Another way to
using :func:`zip`: ``pairs = zip(d.values(), d.keys())``. Another way to
create the same list is ``pairs = [(v, k) for (k, v) in d.items()]``.
create the same list is ``pairs = [(v, k) for (k, v) in d.items()]``.
Iterating views while adding or deleting entries in the dictionary may raise
Iterating views while adding or deleting entries in the dictionary may raise
a :exc:`RuntimeError` or fail to iterate over all entries.
a :exc:`RuntimeError` or fail to iterate over all entries.
.. versionchanged:: 3.7
Dict order is guaranteed to be insertion order.
.. describe:: x in dictview
.. describe:: x in dictview
Return ``True`` if *x* is in the underlying dictionary's keys, values or
Return ``True`` if *x* is in the underlying dictionary's keys, values or
...
@@ -4293,9 +4293,9 @@ An example of dictionary view usage::
...
@@ -4293,9 +4293,9 @@ An example of dictionary view usage::
>>> print(n)
>>> print(n)
504
504
>>> # keys and values are iterated over in the same order
>>> # keys and values are iterated over in the same order
(insertion order)
>>> list(keys)
>>> list(keys)
['eggs', '
bacon', 'sausage
', 'spam']
['eggs', '
sausage', 'bacon
', 'spam']
>>> list(values)
>>> list(values)
[2, 1, 1, 500]
[2, 1, 1, 500]
...
@@ -4303,7 +4303,7 @@ An example of dictionary view usage::
...
@@ -4303,7 +4303,7 @@ An example of dictionary view usage::
>>> del dishes['eggs']
>>> del dishes['eggs']
>>> del dishes['sausage']
>>> del dishes['sausage']
>>> list(keys)
>>> list(keys)
['
spam', 'bacon
']
['
bacon', 'spam
']
>>> # set operations
>>> # set operations
>>> keys & {'eggs', 'bacon', 'salad'}
>>> keys & {'eggs', 'bacon', 'salad'}
...
...
Doc/tutorial/datastructures.rst
Dosyayı görüntüle @
dfbbbf16
...
@@ -497,7 +497,7 @@ You can't use lists as keys, since lists can be modified in place using index
...
@@ -497,7 +497,7 @@ You can't use lists as keys, since lists can be modified in place using index
assignments, slice assignments, or methods like :meth:`append` and
assignments, slice assignments, or methods like :meth:`append` and
:meth:`extend`.
:meth:`extend`.
It is best to think of a dictionary as a
n unordered
set of *key: value* pairs,
It is best to think of a dictionary as a set of *key: value* pairs,
with the requirement that the keys are unique (within one dictionary). A pair of
with the requirement that the keys are unique (within one dictionary). A pair of
braces creates an empty dictionary: ``{}``. Placing a comma-separated list of
braces creates an empty dictionary: ``{}``. Placing a comma-separated list of
key:value pairs within the braces adds initial key:value pairs to the
key:value pairs within the braces adds initial key:value pairs to the
...
@@ -509,9 +509,9 @@ pair with ``del``. If you store using a key that is already in use, the old
...
@@ -509,9 +509,9 @@ pair with ``del``. If you store using a key that is already in use, the old
value associated with that key is forgotten. It is an error to extract a value
value associated with that key is forgotten. It is an error to extract a value
using a non-existent key.
using a non-existent key.
Performing ``list(d
.keys()
)`` on a dictionary returns a list of all the keys
Performing ``list(d)`` on a dictionary returns a list of all the keys
used in the dictionary, in
arbitrary
order (if you want it sorted, just use
used in the dictionary, in
insertion
order (if you want it sorted, just use
``sorted(d
.keys())`` instead). [2]_
To check whether a single key is in the
``sorted(d
)`` instead).
To check whether a single key is in the
dictionary, use the :keyword:`in` keyword.
dictionary, use the :keyword:`in` keyword.
Here is a small example using a dictionary::
Here is a small example using a dictionary::
...
@@ -519,16 +519,16 @@ Here is a small example using a dictionary::
...
@@ -519,16 +519,16 @@ Here is a small example using a dictionary::
>>> tel = {'jack': 4098, 'sape': 4139}
>>> tel = {'jack': 4098, 'sape': 4139}
>>> tel['guido'] = 4127
>>> tel['guido'] = 4127
>>> tel
>>> tel
{'
sape': 4139, 'guido': 4127, 'jack': 4098
}
{'
jack': 4098, 'sape': 4139, 'guido': 4127
}
>>> tel['jack']
>>> tel['jack']
4098
4098
>>> del tel['sape']
>>> del tel['sape']
>>> tel['irv'] = 4127
>>> tel['irv'] = 4127
>>> tel
>>> tel
{'
guido': 4127, 'irv': 4127, 'jack': 4098
}
{'
jack': 4098, 'guido': 4127, 'irv': 4127
}
>>> list(tel
.keys()
)
>>> list(tel)
['
irv', 'guido', 'jack
']
['
jack', 'guido', 'irv
']
>>> sorted(tel
.keys()
)
>>> sorted(tel)
['guido', 'irv', 'jack']
['guido', 'irv', 'jack']
>>> 'guido' in tel
>>> 'guido' in tel
True
True
...
@@ -539,7 +539,7 @@ The :func:`dict` constructor builds dictionaries directly from sequences of
...
@@ -539,7 +539,7 @@ The :func:`dict` constructor builds dictionaries directly from sequences of
key-value pairs::
key-value pairs::
>>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])
>>> dict([('sape', 4139), ('guido', 4127), ('jack', 4098)])
{'sape': 4139, '
jack': 4098, 'guido': 4127
}
{'sape': 4139, '
guido': 4127, 'jack': 4098
}
In addition, dict comprehensions can be used to create dictionaries from
In addition, dict comprehensions can be used to create dictionaries from
arbitrary key and value expressions::
arbitrary key and value expressions::
...
@@ -551,7 +551,7 @@ When the keys are simple strings, it is sometimes easier to specify pairs using
...
@@ -551,7 +551,7 @@ When the keys are simple strings, it is sometimes easier to specify pairs using
keyword arguments::
keyword arguments::
>>> dict(sape=4139, guido=4127, jack=4098)
>>> dict(sape=4139, guido=4127, jack=4098)
{'sape': 4139, '
jack': 4098, 'guido': 4127
}
{'sape': 4139, '
guido': 4127, 'jack': 4098
}
.. _tut-loopidioms:
.. _tut-loopidioms:
...
@@ -710,7 +710,3 @@ interpreter will raise a :exc:`TypeError` exception.
...
@@ -710,7 +710,3 @@ interpreter will raise a :exc:`TypeError` exception.
.. [1] Other languages may return the mutated object, which allows method
.. [1] Other languages may return the mutated object, which allows method
chaining, such as ``d->insert("a")->remove("b")->sort();``.
chaining, such as ``d->insert("a")->remove("b")->sort();``.
.. [2] Calling ``d.keys()`` will return a :dfn:`dictionary view` object. It
supports operations like membership test and iteration, but its contents
are not independent of the original dictionary -- it is only a *view*.
Misc/ACKS
Dosyayı görüntüle @
dfbbbf16
...
@@ -1451,6 +1451,7 @@ Ian Seyer
...
@@ -1451,6 +1451,7 @@ Ian Seyer
Dmitry Shachnev
Dmitry Shachnev
Anish Shah
Anish Shah
Daniel Shahaf
Daniel Shahaf
Hui Shang
Mark Shannon
Mark Shannon
Ha Shao
Ha Shao
Richard Shapiro
Richard Shapiro
...
...
Misc/NEWS.d/next/Documentation/2017-12-22-17-29-37.bpo-32337.eZe-ID.rst
0 → 100644
Dosyayı görüntüle @
dfbbbf16
Update documentation related with ``dict`` order.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment