[Tutor] Problems importing random on linux

Adam adam at monkeez.org
Mon Apr 26 15:43:57 EDT 2004

I use a linux machine and win machine at work. My win machine has no 
problem importing random and then using the randint(x,y) module. 
However, when I try and do this on my linux debian machine, I get:

adam at debian:~/python$ ./autoguess.py
Traceback (most recent call last):
  File "./autoguess.py", line 49, in ?
  File "./autoguess.py", line 6, in generatenumber
    target = random.randint(0,100)
AttributeError: 'module' object has no attribute 'randint'

from the code:
import random

def generatenumber():
    target = random.randint(0,100)

What is going on here? I've tried the same small piece of code :
import random
target = random.randing(0,100) at the interpreter and it works, but if I 
try this as an application in a file, it fails.

Any ideas ?


More information about the Tutor mailing list