[Tutor] How to test function using random.randint()?
boB Stepp
robertvstepp at gmail.com
Sun Mar 20 21:29:38 EDT 2016
On Sun, Mar 20, 2016 at 8:19 PM, Ben Finney <ben+python at benfinney.id.au> wrote:
>
> 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.
Can I not use:
if rng is None:
rng = random.Random()
?
When I tested it int the interpreter to see if I could use randint:
py3: rng = random.Random()
py3: rng.randint(1, 6)
4
Am I missing something basic here?
boB
More information about the Tutor
mailing list