[Tutor] How to test function using random.randint()?
Ben Finney
ben+python at benfinney.id.au
Sun Mar 20 21:19:16 EDT 2016
Steven D'Aprano <steve at pearwood.info> writes:
> On Mon, Mar 21, 2016 at 12:18:01AM +1100, Ben Finney wrote:
> > No, I meant what I wrote. The ‘rng’ parameter is expected to be
> > bound to a RNG. If the caller has not specified a custom RNG
> > instance, we bind ‘rng’ to the standard RNG instance found at
> > ‘random.random’.
Steven is right, that name is a function not an RNG.
The code should read::
if rng is None:
rng = random._inst
which is the default RNG instance in the module.
It is also named as an implementation-only attribute, not part of the
module's API. So you may want to find a more reliable API to use.
--
\ “Very few things happen at the right time, and the rest do not |
`\ happen at all. The conscientious historian will correct these |
_o__) defects.” —Mark Twain, _A Horse's Tale_ |
Ben Finney
More information about the Tutor
mailing list