title: python: execute a .py file multiple times?
body: <p>I have about 50 lines of code, which isn't based on any looping variable (which is why I cannot do for loop) but I want to run this code several times so that my output array keeps building up in length. Is there any way to do that? I would like to execute this .py file 10,000 times. Let me know how I can do that. I know normally I would execute it on my terminal by typing </p>
  
  <p>execfile('filename.py') </p>
  
  <p>but how to do this several times?
  Thank you!</p>
  
  <p>example of what's in the .py file:say I have a bunch of distributions I want to calculate chi sq value for, and save all the values in an array chi = [] after the 10,000 iterations, how would I do that for this case?</p>
  
  <pre><code>chi = []
  def chisqg(ydata,ymod,sd=None):  
  
      if sd==None:  
          chisq=np.sum((ydata-ymod)**2)  
      else:  
          chisq=np.sum( ((ydata-ymod)/sd)**2 )  
      return chisq
  
  chi1 = chisqg(y1,mod1,sd=0.1)
  chi.append(chi1)
  </code></pre>