[Python-checkins] r73383 - in python/branches/release26-maint: Doc/library/random.rst Lib/random.py

raymond.hettinger python-checkins at python.org
Fri Jun 12 01:18:54 CEST 2009


Author: raymond.hettinger
Date: Fri Jun 12 01:18:54 2009
New Revision: 73383
Log:
Issue 6261: Clarify behavior of random.uniform().
Modified:
 python/branches/release26-maint/Doc/library/random.rst
 python/branches/release26-maint/Lib/random.py
Modified: python/branches/release26-maint/Doc/library/random.rst
==============================================================================
--- python/branches/release26-maint/Doc/library/random.rst	(original)
+++ python/branches/release26-maint/Doc/library/random.rst	Fri Jun 12 01:18:54 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/branches/release26-maint/Lib/random.py
==============================================================================
--- python/branches/release26-maint/Lib/random.py	(original)
+++ python/branches/release26-maint/Lib/random.py	Fri Jun 12 01:18:54 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

AltStyle によって変換されたページ (->オリジナル) /