On Mon, Aug 24, 2020 at 7:40 AM dn via Python-list <python-list@python.org> wrote: > > On 24/08/2020 09:04, Chris Angelico wrote: > > On Mon, Aug 24, 2020 at 6:39 AM dn via Python-list > > <python-list@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? >
Nope, it's a very important tool. Not for every situation, of course, but there are plenty of times when it's the right thing to do. ChrisA -- https://mail.python.org/mailman/listinfo/python-list