[New-bugs-announce] [issue3918] random.uniform suprisingly (good kind) does not work as documented

Frank Martinez report at bugs.python.org
Sun Sep 21 05:36:55 CEST 2008

New submission from Frank Martinez <python.20.xuinkrbin at spamgourmet.com>:

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.

components: Library (Lib)
messages: 73480
nosy: xuinkrbin
severity: normal
status: open
title: random.uniform suprisingly (good kind) does not work as documented
type: behavior
versions: Python 2.5

Python tracker <report at bugs.python.org>

More information about the New-bugs-announce mailing list