=\preview\attachgui py =\preview\bob pkl skipping \preview\bob pkl more lines omittedpauses for enter key press at matches found in filesvisited the script lists each file it checks as it goestells you which files it is skipping (names that end in extensions not listed in the variable textexts that imply binary data)and pauses for an enter key press each time it announces file containing the search string the search_all script works the same way when it is imported rather than runbut there is no final statistics output line (fcount and vcount live in the module and so would have to be imported to be inspected here) :\pp \dev\examples\pp epython import tools search_all search_all searcher( ' :\temp\pp \examples''mimetypes'more lines omitted pauses for enter key press along the way search_all fcountsearch_all vcount matchesfiles ( however launchedthis script tracks down all references to string in an entire directory treea name of changed book examples fileobjector directoryfor instance it' exactly what was looking for--or at least thought sountil further deliberation drove me to seek more complete and better structured solutionsthe topic of the next section be sure to also see the coverage of regular expressions in the search_all script here searches for simple string in each file with the in string membership expressionbut it would be trivial to extend it to search for regular expression pattern match instead (roughlyjust replace in with call to regular expression object' search methodof coursesuch mutation will be much more trivial after we've learned how also notice the textexts list in example - which attempts to list all possible binary file typesit would be more general and robust to use the mimetypes logic we will meet near the end of this in order to guess file content type from its namebut the skips list provides more control and sufficed for the trees used this script against finally note that for simplicity many of the directory searches in this assume that text is encoded per the underlying platform' unicode default they could open text in binary mode to avoid decoding errorsbut searches might then be inaccurate because of encoding scheme differences in the raw encoded bytes to see how to do betterwatch for the "greputility in ' pyedit guiwhich will apply an encoding name to all the files in searched tree and ignore those text or binary files that fail to decode searching directory trees