summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJos Verlinde <jos_verlinde@hotmail.com>2025-11-06 16:44:40 +0100
committerDamien George <damien@micropython.org>2025-11-26 14:37:58 +1100
commit1c47db32e4096c4fdb978771ef108d93bff28ace (patch)
treeff6736611ac18e02f556bd087f60da589067329d
parent4633d2a0374f79c3306e60b603377606664e8a24 (diff)
docs/library: Document OrderedDict.popitem()'s CPython differences.
Fixes issue #18370. Signed-off-by: Jos Verlinde <jos_verlinde@hotmail.com>
-rw-r--r--docs/library/collections.rst16
1 files changed, 16 insertions, 0 deletions
diff --git a/docs/library/collections.rst b/docs/library/collections.rst
index 6a23e456c..f973e521e 100644
--- a/docs/library/collections.rst
+++ b/docs/library/collections.rst
@@ -101,3 +101,19 @@ Classes
a 2
w 5
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)