Program chaining on Windows

dn PythonList at DancesWithMice.info
Sun Aug 23 16:37:33 EDT 2020


On 23/08/2020 19:31, Rob Cliffe via Python-list wrote:
> On WIndows 10, running Python programs in a DOS box, I would like one 
> Python program to chain to another.  I.e. the first program to be 
> replaced by the second (*not* waiting for the second to finish, as with 
> e.g. os.system).  This doesn't seem a lot to ask, but so far I have been 
> unable to so this.  I am using Python 3.8.3.  Some attempts so far (may 
> be nonsensical):

What is the definition of "finish" in the first program?
Not sure if have understood <<<(*not* waiting for the second to finish, 
as with e.g. os.system)>>>.
In Python, the easiest way to chain two "modules" is to use import. This 
gives full control to the 'import-er'.


> ATTEMPT #1
> ----------------
> # File X1.py
> import os
> print("This is X1")
> os.execl('C:\\Python38\\python.exe', 'X2.py')
> 
> # File X2.py
> print("This is X2")


# File X1.py
import os
def fn():
     print("This is X1")
     os.execl('C:\\Python38\\python.exe', 'X2.py')
     #  !!!!!

# File X2.py
def fn():
     print("This is X2")

# File x3.py
import x1
import x2
x1.fn()
x2.fn()
print( "x3 terminating" )


-- 
Regards =dn


More information about the Python-list mailing list