processes and threading gramwith the second program invoked once for each separate process that is required in the second section we will begin by giving bare-bones introduction to threaded programming then we will create threaded program that has the same functionality as the two programs from the first section combined so as to provide contrast between the multiple processes and the multiple threads approaches and then we will review another threaded programmore sophisticated than the firstthat both hands off work and gathers together all the results using the multiprocessing module ||in some situations we already have programs that have the functionality we need but we want to automate their use we can do this by using python' subprocess module which provides facilities for running other programspassing any command-line options we wantand if desiredcommunicating with them using pipes we saw one very simple example of this in when we used the subprocess call(function to clear the console in platform-specific way but we can also use these facilities to create pairs of "parent-childprogramswhere the parent program is run by the user and this in turn runs as many instances of the child program as necessaryeach with different work to do it is this approach that we will cover in this section in we showed very simple programgrepword pythat searches for word specified on the command line in the files listed after the word in this section we will develop more sophisticated version that can recurse into subdirectories to find files to read and that can delegate the work to as many separate child processes as we like the output is just list of filenames (with pathsfor those files that contain the specified search word the parent program is grepword- py and the child program is grepword-pchild py the relationship between the two programs when they are being run is shown schematically in figure the heart of grepword- py is encapsulated by its main(functionwhich we will look at in three partsdef main()child os path join(os path dirname(__file__)"grepword- -child py"optswordargs parse_options(filelist get_files(argsopts recursefiles_per_process len(filelist/opts count startend files_per_process (len(filelistopts countnumber