I have a python file B with all my function and a main code which is in loop of 0.25 sec, and I want to call this file in a loop in my file A. Can you get my weird mind ?
What I did but only read the loop from file B once :
from FileB import *
import statement only reads the target module one time.
If you have control of both files, I'd suggest that you make your loop a function in file B:
def main(): while t<0.25: #my stuff if __name__ == '__main__': main()
Then you can call it repeatedly from file A:
from fileB import main as Bmain while 1: Bmain()
If you don't have control of the source code for the files (meaning: if the code comes from someone else), there are a few options. Probably the easiest and fastest to code would be to use the
os.system(command) function to run the contents of fileB in a separate process.