FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-83448: Fix dict's __missing__ documentation by bharel · Pull Request #17911 · python/cpython · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .rst  (3) All 1 file type selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
9 changes: 8 additions & 1 deletion Doc/library/stdtypes.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4504,7 +4504,8 @@ can be used interchangeably to index the same dictionary entry.

Return the value for *key* if *key* is in the dictionary, else *default*.
If *default* is not given, it defaults to ``None``, so that this method
never raises a :exc:`KeyError`.
never raises a :exc:`KeyError`. Note that :meth:`get` does not call
:meth:`__missing__` if value does not exist.

.. method:: items()

Expand Down Expand Up @@ -4571,6 +4572,12 @@ can be used interchangeably to index the same dictionary entry.
>>> d.values() == d.values()
False

.. method:: __missing__(key)

Not implemented by default. Called by :class:`dict`\ .\ :meth:`__getitem__`

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality
Suggested change
Not implemented by default. Called by :class:`dict`\ .\ :meth:`__getitem__`
Not implemented by default. Called by :meth:`dict.__getitem__`

to implement ``self[key]`` for dict subclasses when key is not in the
dictionary. See ``d[key]`` above.

.. describe:: d | other

Create a new dictionary with the merged keys and values of *d* and
Expand Down
6 changes: 0 additions & 6 deletions Doc/reference/datamodel.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -2547,12 +2547,6 @@ through the object's keys; for sequences, it should iterate through the values.
values as for the :meth:`__getitem__` method.


.. method:: object.__missing__(self, key)

Called by :class:`dict`\ .\ :meth:`__getitem__` to implement ``self[key]`` for dict subclasses
when key is not in the dictionary.


.. method:: object.__iter__(self)

This method is called when an :term:`iterator` is required for a container.
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix :meth:`__missing__` documentation. It is implemented only by
:class:`dict` and not being used by :meth:`dict.get`. Patch by Bar Harel.

Back | FazBrowse Home | New Git URL