Hi,<br> I wrote a random walk program which you will find below. When I run it from the terminal, it gives error which I am not able to figure out what could be wrong. From the bash shell, I give a command <br> >python2.4 random.py<br> It gives error:<br> -----------------------------------------------------------------------------------------<br> Traceback (most recent call last):<br> File "random.py", line 2, in ?<br> from pylab import *<br> File "/usr/lib/python2.4/site-packages/pylab.py", line 1, in ?<br> from matplotlib.pylab import *<br> File "/usr/lib/python2.4/site-packages/matplotlib/pylab.py", line 196, in ?<br> import mlab #so I can override hist, psd, etc...<br> File "/usr/lib/python2.4/site-packages/matplotlib/mlab.py", line 58, in ?<br> import sys, random<br> File "/home/ofenerci/workspace/random.py", line
11, in ?<br> if (rand() > 0.5):<br> NameError: name 'rand' is not defined<br> [3] Done gedit random.py<br> -------------------------------------------------------------------------------------------------------------<br> When I write the program step by step inside the python2.4 shell or run it inside the python2.4-idle, everything goes smoothly and it doesn't give any error. I don't know why gives error, If I run it from the terminal.<br> <br> thanks,<br> Ahmet Nurlu<br> <br> Random.py Program:<br> ---------------------------------------------------------------------------<br> from pylab import *<br> <br> npts=1000<br> nplot=10<br> for i in range(0,nplot):<br> <br> xplot=[]<br> x=0.0<br> for i in range(0,npts):<br>
if (rand() > 0.5):<br> x=x+1<br> else:<br> x=x-1<br> xplot.append(x)<br> plot(xplot,'g')<br> hold(True)<br> show()<br> -------------------------------------------------------------------------<p>
<hr size=1> Yahoo! Mail<br>
<a href="http://us.rd.yahoo.com/mail_us/taglines/pmall2/*http://photomail.mail.yahoo.com">Use Photomail</a> to share photos without annoying attachments.