[Tutor] random numbers

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Wed May 28 14:09:01 2003


On Wed, 28 May 2003, Jennifer Cianciolo wrote:

> Ok, I did have a file named random.py.  I guess that's not a good idea!!

Hi Jennifer,

Yes, I'm glad we sorted that out.



> I deleted it, but the random.random() is still not working.

You may want to check if there's a 'random.pyc' in your current directory.
What's probably happening is that Python has "cached" what it thinks is
the real 'random.py' module.  If you delete that 'random.pyc' from your
current directory, try importing 'random' again then and see if things
work.



For some wacky reason, this sort of problem always seems to happen with
the random module: people have this undeniable compulsion to name their
test file 'random' when they want to test out the random number
generator... *grin*

Good luck!