tags:

views:

50

answers:

1

I have a program 'a.py' which start with:

import XXX

The import works perfectly and a.py runs fine.

Then I wrote a program 'b.py' which calls 'a.py' to run continuously. It looks like this:

import os

def main():

return os.system("a.py") 

c=main()

while(c):

c=main()

The I got the error says that 'Import error: no module named XXX'

Can anyone please tell me what's wrong?

Both a.py and b.py are in the same folder.

A: 

Instead of using os.system, why don't you do an

import a

in b.py, and then call the function you want to run from a.py directly?

zerocrates
I want to run a.py from the begging to the end, basically, if a.py terminates, I would like to restart it. That's why I am having b.py to control this process
Beryl