Program chaining on Windows

dn PythonList at DancesWithMice.info
Sun Aug 23 17:38:57 EDT 2020


On 24/08/2020 09:04, Chris Angelico wrote:
> On Mon, Aug 24, 2020 at 6:39 AM dn via Python-list
> <python-list at python.org> wrote:
>>
>> 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'.
>>
> 
> With exec, the intention is to *replace* the current program, not to
> invoke it and wait till it's done. The current program will not
> continue after a successful exec.


As a 'general rule', isn't exec() something to be avoided?

With an appropriate conditional control between the three modules, and 
bearing @Eryk's observations in-mind (and the lack of specifics in the 
OP), won't the import option succeed and won't all of file1's attributes 
be garbage-collected? Same effect, or something missing?
-- 
Regards =dn


More information about the Python-list mailing list