[Tutor] Problems importing random on linux
orbitz at ezabel.com
orbitz at ezabel.com
Mon Apr 26 15:51:02 EDT 2004
Sounds like you might have 2 version of python on your system. Check for
multiple python binaries. also try running your script with: python
autoguess.py and see what happens.
On Mon, 26 Apr 2004 20:43:57 +0100
Adam <adam at monkeez.org> wrote:
> 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 ?
> generatenumber()
> 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 ?
>
> adam
>
> _______________________________________________
> Tutor maillist - Tutor at python.org
> http://mail.python.org/mailman/listinfo/tutor
More information about the Tutor
mailing list