[Python-checkins] r73380 - in python/branches/py3k: Doc/library/random.rst Lib/random.py

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

```Author: raymond.hettinger
Date: Fri Jun 12 01:12:14 2009
New Revision: 73380

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

Modified:
python/branches/py3k/Doc/library/random.rst
python/branches/py3k/Lib/random.py

Modified: python/branches/py3k/Doc/library/random.rst
==============================================================================
--- python/branches/py3k/Doc/library/random.rst	(original)
+++ python/branches/py3k/Doc/library/random.rst	Fri Jun 12 01:12:14 2009
@@ -142,6 +142,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/py3k/Lib/random.py
==============================================================================
--- python/branches/py3k/Lib/random.py	(original)
+++ python/branches/py3k/Lib/random.py	Fri Jun 12 01:12:14 2009
@@ -333,7 +333,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 --------------------
```