import random module

Diez B. Roggisch deets at nospam.web.de
Wed Mar 22 11:56:44 EST 2006


DataSmash wrote:

> Hi,
> When I import the random module at the python interpreter, it works
> fine:
>>>> import random
>>>> x = random.randint(1,55)
>>>> print x
> 14
>>>>
> 
> BUT, when I put the same code in a python script:
> * random.py:

^^^^^^

There is your problem: you named your module "random", so importing random
will cause your own module to be imported. Rename it, and everything will
be fine.

Diez



More information about the Python-list mailing list