[Python-checkins] [3.11] Backport docstring improvement from 3.12 (#98288)

rhettinger webhook-mailer at python.org
Sat Oct 15 14:11:09 EDT 2022


https://github.com/python/cpython/commit/099620b0ce964ffe85fc52a7595ece13a55ca81c
commit: 099620b0ce964ffe85fc52a7595ece13a55ca81c
branch: 3.11
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2022-10-15T13:11:04-05:00
summary:

[3.11] Backport docstring improvement from 3.12 (#98288)

Backport docstring improvement from 3.12

files:
M Lib/random.py

diff --git a/Lib/random.py b/Lib/random.py
index 1f3530e880fc..f94616e048c5 100644
--- a/Lib/random.py
+++ b/Lib/random.py
@@ -282,10 +282,10 @@ def randbytes(self, n):
     ## -------------------- integer methods  -------------------
 
     def randrange(self, start, stop=None, step=_ONE):
-        """Choose a random item from range(start, stop[, step]).
+        """Choose a random item from range(stop) or range(start, stop[, step]).
 
-        This fixes the problem with randint() which includes the
-        endpoint; in Python this is usually not what you want.
+        Roughly equivalent to ``choice(range(start, stop, step))`` but
+        supports arbitrarily large ranges and is optimized for common cases.
 
         """
 



More information about the Python-checkins mailing list