in factby passing in the desired mode flagwe redirect either spawned program' output or input streams to file in the calling scriptsand we can obtain the spawned program' exit status code from the close method (none means "no errorhereto illustrateconsider the following two scriptsc:\pp \system\streamstype hello-out py print('hello shell world' :\pp \system\streamstype hello-in py inp input(open('hello-in txt'' 'write('hello inp '\ 'these scripts can be run from system shell window as usualc:\pp \system\streamspython hello-out py hello shell world :\pp \system\streamspython hello-in py brian :\pp \system\streamstype hello-in txt hello brian as we saw in the prior python scripts can read output from other programs and scripts like thesetoousing code like the followingc:\pp \system\streamspython import os pipe os popen('python hello-out py'pipe read('hello shell world\nprint(pipe close()none 'ris default--read stdout exit statusnone is good but python scripts can also provide input to spawned programsstandard input streams--passing "wmode argumentinstead of the default " "connects the returned object to the spawned program' input stream what we write on the spawning end shows up as input in the program startedpipe os popen('python hello-in py'' 'pipe write('gumby\ ' pipe close(open('hello-in txt'read('hello gumby\ ' '--write to program stdin \ at end is optional output sent to file the popen call is also smart enough to run the command string as an independent process on platforms that support such notion it accepts an optional third argument that can be used to control buffering of written textwhich we'll finesse here standard streams