Your original post showed this traceback:
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python25\swampy.1.1\TurtleWorld.py", line 1, in <module>
    from World import *
  File "C:\Python25\swampy.1.1\World.py", line 29, in <module>
    import random
  File "C:\Python25\random.py", line 4, in <module>
    i = random.randrange(10,50)
AttributeError: 'module' object has no attribute 'randrange'

Which would suggest that the file World.py imported a file called 
random.py from the directory  C:\Python25\random.py
The random module that comes with python is typically stored in  the 
directory C:\Python25\Lib
and never contains the line:  i = random.randrange(10,50)

So I would look for a .py or .pyc file in your Python25 folder called 
random and remove it like Kent said.

Hope that works.

Chris 




"Guess?!?" <[EMAIL PROTECTED]> 
Sent by: [EMAIL PROTECTED]
05/15/2008 03:48 PM

To
"Kent Johnson" <[EMAIL PROTECTED]>
cc
tutor@python.org
Subject
Re: [Tutor] Random module error






Hello Kent,
 
I dont have any program with name random.py. I am using swampy API (
http://allendowney.com/swampy/install.html)
As instructed by author, I do following steps
 
1> unzip/extract the folder into Python directory
2> go to the swampy directory
3> and invoke python command to start interpreter
4> as soon as I write from TurtleWorld import *
 
I get that error ..... I checked inside the folder ...there is no 
random.py and 
i checked TurtleWorld.py ....there is only reference to standard module 
"random"
 
Thnks
G
 
 


 
On Thu, May 15, 2008 at 5:00 AM, Kent Johnson <[EMAIL PROTECTED]> wrote:
On Thu, May 15, 2008 at 3:00 AM, Guess?!? <[EMAIL PROTECTED]> wrote:
> Hello All,
>
> I am importing module "random" and it is giving me this error
> below  AttributeError: 'module' object has no attribute 'randrange'

You have named your program random.py. The import finds your program
rather than the random module. Rename your program and delete the
associated .pyc file and it will work.

Kent
_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

_______________________________________________
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor

Reply via email to