From: Miss Islington (bot) <31488909+miss-islington@users.noreply.github.com> Date: Sat, 18 Jan 2025 20:58:20 +0000 (+0100) Subject: [3.13] gh-128998: Fix indentation of numbered list and literal block (GH-128999)... X-Git-Tag: v3.13.2~85 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=03ee311e5a454dce665f14deac91687a752e1679;p=thirdparty%2FPython%2Fcpython.git [3.13] gh-128998: Fix indentation of numbered list and literal block (GH-128999) (#129000) gh-128998: Fix indentation of numbered list and literal block (GH-128999) (cherry picked from commit e8092e5cdcd6707ac0b16d8fb37fa080a88bcc97) Co-authored-by: Rafael Fontenelle Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com> --- diff --git a/Doc/faq/programming.rst b/Doc/faq/programming.rst index fa7b22bde1dc..776bab1ed5b7 100644 --- a/Doc/faq/programming.rst +++ b/Doc/faq/programming.rst @@ -1906,28 +1906,30 @@ In the standard library code, you will see several common patterns for correctly using identity tests: 1) As recommended by :pep:`8`, an identity test is the preferred way to check -for ``None``. This reads like plain English in code and avoids confusion with -other objects that may have boolean values that evaluate to false. + for ``None``. This reads like plain English in code and avoids confusion + with other objects that may have boolean values that evaluate to false. 2) Detecting optional arguments can be tricky when ``None`` is a valid input -value. In those situations, you can create a singleton sentinel object -guaranteed to be distinct from other objects. For example, here is how -to implement a method that behaves like :meth:`dict.pop`:: + value. In those situations, you can create a singleton sentinel object + guaranteed to be distinct from other objects. For example, here is how + to implement a method that behaves like :meth:`dict.pop`: - _sentinel = object() + .. code-block:: python - def pop(self, key, default=_sentinel): - if key in self: - value = self[key] - del self[key] - return value - if default is _sentinel: - raise KeyError(key) - return default + _sentinel = object() + + def pop(self, key, default=_sentinel): + if key in self: + value = self[key] + del self[key] + return value + if default is _sentinel: + raise KeyError(key) + return default 3) Container implementations sometimes need to augment equality tests with -identity tests. This prevents the code from being confused by objects such as -``float('NaN')`` that are not equal to themselves. + identity tests. This prevents the code from being confused by objects + such as ``float('NaN')`` that are not equal to themselves. For example, here is the implementation of :meth:`!collections.abc.Sequence.__contains__`::