By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,064 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

New to group

P: n/a
Hi Everyone

I am new to programming in general although I have read alot and
done alot of experimentation as well as researched afew languages
namely java python and visual basic . My conclusion is that python
is one of the best because it eliminates the need to learn about
access modifiers and form handlers so a user can concentrate
primarliy on the nuts and bolts of the language .

i have come across my first exeption using randrange . The exeption
is " no such attribute " in module random

platform is xp home and the python build is activestate 2.5

All help much appreciated !

Mar 24 '08 #1
Share this Question
Share on Google+
8 Replies


P: n/a
What does the code look like?
Mar 24 '08 #2

P: n/a
On Mar 24, 1:53 pm, pythonnubie <exxf...@hotmail.comwrote:
Hi Everyone

I am new to programming in general although I have read alot and
done alot of experimentation as well as researched afew languages
namely java python and visual basic . My conclusion is that python
is one of the best because it eliminates the need to learn about
access modifiers and form handlers so a user can concentrate
primarliy on the nuts and bolts of the language .

i have come across my first exeption using randrange . The exeption
is " no such attribute " in module random

platform is xp home and the python build is activestate 2.5

All help much appreciated !
Please post the code that throws this error along with the entire
traceback.

Thanks,

Mike
Mar 24 '08 #3

P: n/a
On Mar 24, 11:57*am, Jeff <jeffo...@gmail.comwrote:
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 !

Mar 24 '08 #4

P: n/a
On Mar 24, 2:53 pm, pythonnubie <exxf...@hotmail.comwrote:
Hi Everyone

I am new to programming in general although I have read alot and
done alot of experimentation as well as researched afew languages
namely java python and visual basic . My conclusion is that python
is one of the best because it eliminates the need to learn about
access modifiers and form handlers so a user can concentrate
primarliy on the nuts and bolts of the language .

i have come across my first exeption using randrange . The exeption
is " no such attribute " in module random

platform is xp home and the python build is activestate 2.5
Welcome aboard!

There's definitely a randrange function in the random module, so
something else must be wrong. To get the most out of this list and
minimize wasted bandwidth, the most effective way usually consists of
copying and pasting:
1. The offending code (or just the relevant part if it's too big).
2. The full traceback of the raised exception.

Regards,
George
Mar 24 '08 #5

P: n/a
On Mar 24, 3:03 pm, pythonnubie <exxf...@hotmail.comwrote:
On Mar 24, 11:57 am, Jeff <jeffo...@gmail.comwrote:
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 !
It works fine on on Windows with standard Python 2.5. Something is
probably wrong with your ActiveState installation.

George
Mar 24 '08 #6

P: n/a
pythonnubie wrote:
On Mar 24, 11:57 am, Jeff <jeffo...@gmail.comwrote:
>What does the code look like?

# Random Access
# Demonstrates string indexing
# Michael Dawson - 1/27/03

import random
Make sure that you do not have a random.py module in the current directory.
Python checks the current directory for modules before the standard directories.

--
Robert Kern

"I have come to believe that the whole world is an enigma, a harmless enigma
that is made terrible by our own mad attempt to interpret it as though it had
an underlying truth."
-- Umberto Eco

Mar 24 '08 #7

P: n/a
pythonnubie wrote:
The exeption
is " no such *attribute " in *module random
Is your own source file named "random.py" by chance? If so, rename it, and
be sure to remove the leftover random.pyc file as well.
Jeffrey
Mar 24 '08 #8

P: n/a
pythonnubie wrote:
On Mar 24, 11:57*am, Jeff <jeffo...@gmail.comwrote:
>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
Mar 24 '08 #9

This discussion thread is closed

Replies have been disabled for this discussion.