Re: creating an instance of a random number generator

Hannu Krosing (hannu@estib.ee)
10 Apr 1995 15:15:16 GMT

jps@tfs.com (Jeff Stearns) wrote:
>> I am thinking that saying
> import whrandom
> wh = whrandom(seed1, seed2, seed3)
> should give me an instance of a random-number generator; I could then
> use it by saying
> rand = wh.random()
>
> Python disagrees; it claims that "wh = whrandom(seed1, seed2, seed3)"
> is a "call of a non-function".

Here's what I get:
>>> import whrandom
>>> whrandom
<module 'whrandom'>
>>> dir(whrandom)
['__builtins__', '__doc__', '__name__', '_inst', 'choice', 'randint', 'random',
'seed', 'uniform', 'whrandom']
>>> whrandom.whrandom
<class whrandom at 7aaf0>
>>>

if you want whrandom to be a function, you should say
>>> from whrandom import *

You have probably figured it out yourself by now :)

Hannu Krosing / hannu@estib.ee