Title: random.uniform suprisingly (good kind) does not work as documented
Type: behavior Stage:
Components: Library (Lib) Versions: Python 2.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: georg.brandl, xuinkrbin
Priority: normal Keywords:

Created on 2008-09-21 03:36 by xuinkrbin, last changed 2008-09-21 08:03 by georg.brandl. This issue is now closed.

Messages (2)
msg73480 - (view) Author: Frank Martinez (xuinkrbin) Date: 2008-09-21 03:36
The documentation for random.uniform states:
    uniform(a, b)
        Return a random real number N such that a <= N < b.
However when I test it out, We see:
    >>> import random as r
    >>> r.uniform(0,-1)
    >>> r.uniform(0,-1)
    >>> r.uniform(0,-1)
    >>> r.uniform(-1,0)
    >>> r.uniform(3,2)
Now, while /I/ actually find this behavior *extremely* useful (I don't 
need to verify I call with the arguments in the `correct' order.), I 
think either the behavior needs to change to match the documentation or 
(preferably), the documentation needs alteration to read, for example, 
    If a > b, this function behaves as if it were called as uniform(b,a).
Again, for clarity, I vote for the documentation change.
msg73502 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-09-21 08:03
Noted in r66535.
Date User Action Args
2008-09-21 08:03:28georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg73502
nosy: + georg.brandl
2008-09-21 03:36:54xuinkrbincreate