https://github.com/python/cpython/commit/4152bbb773149fa0df0a6afc594ca372da6f5f86
commit: 4152bbb773149fa0df0a6afc594ca372da6f5f86
branch: 3.14
author: Miss Islington (bot) <[email protected]>
committer: picnixz <[email protected]>
date: 2026-02-28T19:28:14Z
summary:

[3.14] gh-145269: simplify bisect.bisect doc example (GH-145270) (#145367)

gh-145269: simplify bisect.bisect doc example (GH-145270)



---------
(cherry picked from commit fdb4b3527f356a84bc00ca32516181016400e567)

Co-authored-by: Nathan Goldbaum <[email protected]>
Co-authored-by: Pieter Eendebak <[email protected]>

files:
M Doc/library/bisect.rst
M Lib/test/test_bisect.py

diff --git a/Doc/library/bisect.rst b/Doc/library/bisect.rst
index 3efa3999171646..ecc8d69a2b39ca 100644
--- a/Doc/library/bisect.rst
+++ b/Doc/library/bisect.rst
@@ -203,9 +203,9 @@ example uses :py:func:`~bisect.bisect` to look up a letter 
grade for an exam sco
 based on a set of ordered numeric breakpoints: 90 and up is an 'A', 80 to 89 is
 a 'B', and so on::
 
-   >>> def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):
-   ...     i = bisect(breakpoints, score)
-   ...     return grades[i]
+   >>> def grade(score)
+   ...     i = bisect([60, 70, 80, 90], score)
+   ...     return "FDCBA"[i]
    ...
    >>> [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
    ['F', 'A', 'C', 'C', 'B', 'A', 'A']
diff --git a/Lib/test/test_bisect.py b/Lib/test/test_bisect.py
index 97204d4cad3871..a7e1f533ff2adc 100644
--- a/Lib/test/test_bisect.py
+++ b/Lib/test/test_bisect.py
@@ -391,9 +391,9 @@ class TestErrorHandlingC(TestErrorHandling, 
unittest.TestCase):
 
 class TestDocExample:
     def test_grades(self):
-        def grade(score, breakpoints=[60, 70, 80, 90], grades='FDCBA'):
-            i = self.module.bisect(breakpoints, score)
-            return grades[i]
+        def grade(score):
+            i = self.module.bisect([60, 70, 80, 90], score)
+            return "FDCBA"[i]
 
         result = [grade(score) for score in [33, 99, 77, 70, 89, 90, 100]]
         self.assertEqual(result, ['F', 'A', 'C', 'C', 'B', 'A', 'A'])

_______________________________________________
Python-checkins mailing list -- [email protected]
To unsubscribe send an email to [email protected]
https://mail.python.org/mailman3//lists/python-checkins.python.org
Member address: [email protected]

Reply via email to