mirror of
https://github.com/micropython/micropython.git
synced 2025-12-16 09:50:15 +01:00
docs/library: Document OrderedDict.popitem()'s CPython differences.
Fixes issue #18370. Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
This commit is contained in:
committed by
Damien George
parent
4633d2a037
commit
1c47db32e4
@@ -101,3 +101,19 @@ Classes
|
|||||||
a 2
|
a 2
|
||||||
w 5
|
w 5
|
||||||
b 3
|
b 3
|
||||||
|
|
||||||
|
.. method:: OrderedDict.popitem()
|
||||||
|
|
||||||
|
Remove and return a (key, value) pair from the dictionary.
|
||||||
|
Pairs are returned in LIFO order.
|
||||||
|
|
||||||
|
.. admonition:: Difference to CPython
|
||||||
|
:class: attention
|
||||||
|
|
||||||
|
``OrderedDict.popitem()`` does not support the ``last=False`` argument and
|
||||||
|
will always remove and return the last item if present.
|
||||||
|
|
||||||
|
A workaround for this is to use ``pop(<first_key>)`` to remove the first item::
|
||||||
|
|
||||||
|
first_key = next(iter(d))
|
||||||
|
d.pop(first_key)
|
||||||
|
|||||||
Reference in New Issue
Block a user