467,075 Members | 1,025 Online
Bytes | Developer Community
Ask Question

Home New Posts Topics Members FAQ

Post your question to a community of 467,075 developers. It's quick & easy.

help in execfile function

Hi

i have 3 python files and i want to execute the files sequentially
using the execfile command.Hence ,i have written the following program
fileList = ["a.py","b.py","c.py"]

for fileName in fileList :
execfile(fileName)

however,when i try running it,the program keeps calling execfile on
a.py and thus an infinite loop is created.I am running this on Windows
XP.

Please suggest a sloution whereby i can use execfile to execute all
files in fileList.Please tell me where in my program i may have gone
wrong.

moijes12
Sep 4 '08 #1
  • viewed: 1344
Share:
1 Reply
On Thu, 04 Sep 2008 05:03:57 -0700, moijes12 wrote:
Hi

i have 3 python files and i want to execute the files sequentially using
the execfile command.Hence ,i have written the following program
fileList = ["a.py","b.py","c.py"]

for fileName in fileList :
execfile(fileName)

however,when i try running it,the program keeps calling execfile on a.py
and thus an infinite loop is created.I am running this on Windows XP.
Change the line "execfile(fileName)" to "print fileName" and you may
discover that the problem isn't with execfile but with your code.

Then read about modules and import, and you may discover that there is a
better way than execfile.
(I wish that eval, exec and execfile were hidden in a module where noobs
couldn't trip over them and decide they are the answer to every problem.
Sigh.)

Please suggest a sloution whereby i can use execfile to execute all
files in fileList.Please tell me where in my program i may have gone
wrong.
Looking into my crystal ball, I'm guessing that file a.py contains a line
that says "execfile('a.py')".

--
Steven
Sep 4 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by Jonathan | last post: by
3 posts views Thread by v.vayer@gmail.com | last post: by
2 posts views Thread by Mardy | last post: by
3 posts views Thread by Mardy | last post: by
2 posts views Thread by Alex Popescu | last post: by
1 post views Thread by Fernando Perez | last post: by
2 posts views Thread by Dave Westerman | last post: by
5 posts views Thread by George Sakkis | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.