Calling a file in python -
i'd call .py file within python. in same directory. effectivly, same behavior calling python foo.py command line without using of command line tools. how should this?
it's not quite clear (at least me) mean using "none of command-line tools".
to run program in subprocess, 1 uses subprocess
module. however, if both calling , callee python scripts, there alternative, use multiprocessing
module.
for example, can organize foo.py this:
def main(): ... if __name__=='__main__': main()
then in calling script, test.py:
import multiprocessing mp import foo proc=mp.process(target=foo.main) proc.start() # stuff while foo.main running # wait until foo.main has ended proc.join() # continue doing more stuff
Comments
Post a Comment