random number including 1 - i.e. [0,1]
gallium.arsenide at gmail.com
Wed Jun 10 08:25:39 CEST 2009
On Jun 10, 1:52 am, Steven D'Aprano
<ste... at REMOVE.THIS.cybersource.com.au> wrote:
> On Tue, 09 Jun 2009 22:21:26 -0700, John Yeung wrote:
> > Therefore, to me the most up-to-date docs (which say
> > that uniform(a, b) returns a float in the closed
> > interval [a, b]) is closer to correct than before,
> > but still fails to point out the full subtlety of
> > the behavior.
> Which is?
That uniform(a, b) will return a random float in the semi-open
interval [a, b) for certain values of a and b; and in the closed
interval [a, b] for other values of a and b. (Swap a and b if a > b.)
To me, the fact that you sometimes get a semi-open interval and
sometimes a closed interval is worth noting in the docs.
More information about the Python-list