[Python-checkins] r73382 - in python/trunk: Doc/library/random.rst Lib/random.py

raymond.hettinger python-checkins at python.org
Fri Jun 12 01:14:53 CEST 2009


Author: raymond.hettinger
Date: Fri Jun 12 01:14:53 2009
New Revision: 73382

Log:
Issue 6261: Clarify behavior of random.uniform().

Modified:
   python/trunk/Doc/library/random.rst
   python/trunk/Lib/random.py

Modified: python/trunk/Doc/library/random.rst
==============================================================================
--- python/trunk/Doc/library/random.rst	(original)
+++ python/trunk/Doc/library/random.rst	Fri Jun 12 01:14:53 2009
@@ -191,6 +191,8 @@
    Return a random floating point number *N* such that ``a <= N <= b`` for
    ``a <= b`` and ``b <= N <= a`` for ``b < a``.
 
+   The end-point value ``b`` may or may not be included in the range
+   depending on floating-point rounding in the equation ``a + (b-a) * random()``.
 
 .. function:: triangular(low, high, mode)
 

Modified: python/trunk/Lib/random.py
==============================================================================
--- python/trunk/Lib/random.py	(original)
+++ python/trunk/Lib/random.py	Fri Jun 12 01:14:53 2009
@@ -349,7 +349,7 @@
 ## -------------------- uniform distribution -------------------
 
     def uniform(self, a, b):
-        """Get a random number in the range [a, b)."""
+        "Get a random number in the range [a, b) or [a, b] depending on rounding."
         return a + (b-a) * self.random()
 
 ## -------------------- triangular --------------------


More information about the Python-checkins mailing list