processes and threading the python interpreterbut we prefer this approach because it ensures that the child program uses the same python interpreter as the parent program once we have the command ready we create subprocess popen objectspecifying the command to execute (as list of strings)and in this case requesting to write to the process' standard input (it is also possible to read process' standard output by setting similar keyword argument we then write the search word followed by newline and then every file in the relevant slice of the file list the subprocess module reads and writes bytesnot stringsbut the processes it creates always assume that the bytes received from sys stdin are strings in the local encoding--even if the bytes we have sent use different encodingsuch as utf- which we have used here we will see how to get around this annoying problem shortly once the word and the list of files have been written to the child processwe close its standard input and move on it is not strictly necessary to keep reference to each process (the pipe variable gets rebound to new subprocess popen object each time through the loop)since each process runs independentlybut we add each one to list so that we can make them interruptible alsowe don' gather the results togetherbut instead we let each process write its results to the console in its own time this means that the output from different processes could be interleaved (you will get the chance to avoid interleaving in the exercises while pipespipe pipes pop(pipe wait(once all the processes have started we wait for each child process to finish this is not essentialbut on unix-like systems it ensures that we are returned to the console prompt when all the processes are done (otherwisewe must press enter when they are all finishedanother benefit of waiting is that if we interrupt the program ( by pressing ctrl+ )all the processes that are still running will be interrupted and will terminate with an uncaught keyboardinterrupt exception--if we did not wait the main program would finish (and therefore not be interruptible)and the child processes would continue (unless killed by kill program or task managerapart from the comments and importshere is the complete grepword-pchild py program we will look at the program in two parts--with two versions of the first partthe first for any python version and the second for python or later versionsblock_size number "{ }format(sys argv[ ]if len(sys argv= else "stdin sys stdin buffer read(lines stdin decode("utf ""ignore"splitlines(word lines[ rstrip(