os.system vs subrocess.call

Stephan Lukits stephan.lukits at gmail.com
Thu Nov 28 05:44:50 EST 2019



> On 28. Nov 2019, at 12:05, Ulrich Goebel <ml at fam-goebel.de> wrote:
> 
> Hi,
> 
> I have to call commands from inside a python skript. These commands are in fact other python scripts. So I made
> 
>    os.system('\.Test.py')
> 
> That works.
> 
> Now I tried to use
> 
>    supprocess.call(['.\', 'test.py'])

[ins] In [1]: from os import system

[ins] In [2]: system('./test.py')
hallo world
Out[2]: 0

[ins] In [3]: from subprocess import call

[ins] In [4]: call('./test.py')
hallo world
Out[4]: 0

In the first call you call ’.Test.py’
In the second call you call ’test.py’

“supprocess” doesn’t exist

How about

subprocess.call(‘\.Test.py’)

Or

subprocess.call([‘\.Test.py’])

Whereas the later makes more sense if you want to pass arguments to Test.py

Greetings Stephan


More information about the Python-list mailing list