New to group

Peter Otten __peter__ at web.de
Mon Mar 24 15:15:16 EDT 2008


pythonnubie wrote:

> On Mar 24, 11:57 am, Jeff <jeffo... at gmail.com> wrote:
>> What does the code look like?
> 
> # Random Access
> # Demonstrates string indexing
> # Michael Dawson - 1/27/03
> 
> import random
> 
> word = "index"
> print "The word is: ", word, "\n"
> 
> high = len(word)
> low = -len(word)
> for i in range(10):
>     position = random.randrange(low, high)
>     print "word[", position, "]\t", word[position]
> 
> raw_input("\n\nPress the enter key to exit.")
> 
> The  code is an exerp from  a  chm file . I  am petty sutre I  am
> nmot  getting  a  char  map error from  the copy/paste ! it looks
> simple enough !

You have probably called your script random.py, and now it imports itself
instead of the random.py module in Python's standard library.

Rename your script to myrandom.py, remove the compiled version random.pyc in
the same folder, and you should be able to run it successfully.

Peter



More information about the Python-list mailing list