Random Number Generator Error
Fredrik Lundh
fredrik at pythonware.com
Sat Mar 18 04:55:07 EST 2006
"ahmet nurlu" wrote:
> It gives error:
> Traceback (most recent call last):
> File "random.py", line 2, in ?
> from pylab import *
> File "/usr/lib/python2.4/site-packages/pylab.py", line 1, in ?
> from matplotlib.pylab import *
> File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 196, in ?
> import mlab #so I can override hist, psd, etc...
> File "/usr/lib/python2.4/site-packages/matplotlib/mlab.py", line 58, in ?
> import sys, random
> File "/home/ofenerci/workspace/random.py", line 11, in ?
> if (rand() > 0.5):
> NameError: name 'rand' is not defined
> [3] Done gedit random.py
if you look at the filenames in that traceback, you'll notice that when
matplotlib imports the random module, it loads your test program instead
of the expected standard library module.
to fix this, rename your test program.
</F>
More information about the Python-list
mailing list