list interactively as we did here (see also "subprocessos popenand iteratorson page for more on the subjectso farwe've run basic dos commandsbecause these calls can run any command line that we can type at shell promptthey can also be used to launch other python scripts assuming your system search path is set to locate your python (so that you can use the shorter "pythonin the following instead of the longer " :\python \python")os system('python helloshell py'run python program the meaning of life output os popen('python helloshell py'read(output 'the meaning of life\nin all of these examplesthe command-line strings sent to system and popen are hardcodedbut there' no reason python programs could not construct such strings at runtime using normal string operations (+%etc given that commands can be dynamically built and run this waysystem and popen turn python scripts into flexible and portable tools for launching and orchestrating other programs for examplea python test "driverscript can be used to run programs coded in any language ( ++javapythonand analyze their output we'll explore such script in we'll also revisit os popen in the next in conjunction with stream redirectionas we'll findthis call can also send input to programs the subprocess module alternative as mentionedin recent releases of python the subprocess module can achieve the same effect as os system and os popenit generally requires extra code but gives more control over how streams are connected and used this becomes especially useful when streams are tied in more complex ways for exampleto run simple shell command like we did with os system earlierthis new module' call function works roughly the same (running commands like "typethat are built into the shell on windows requires extra protocolthough normal executables like "pythondo not)import subprocess subprocess call('python helloshell py'the meaning of life subprocess call('cmd / "type helloshell py"' python program print('the meaning of life' subprocess call('type helloshell py'shell=truea python program print('the meaning of life' roughly like os system(built-in shell cmd alternative for built-ins introducing the os module