HowTo exec every line of a file inside python program

Joe Richett etjo at freenet.de
Wed Feb 11 10:36:47 EST 2004


Hi all,

I have a python program and I have some "user defined" command stored in 
a separate text file. Is there a builtin command with which I can load 
the "user defined"-file and execute every command line by line, e.g.

#
# MAIN PROGRAM
#

def a(i):
   print "here we are #", i

if __name__ == "__main__":
   for i in range(10):
     a(i)
     <execute everything from FILE.PY>

------------------------------------------------------

#
# USER DEFINED FILE
#
print "here we are in the user defined file"





More information about the Python-list mailing list