searchvisitor (two separate traversals are performedthe first argument is really used as bit mask to select one or more supported self-testsif test' bit is on in the binary value of the argumentthe test will be run because is in binaryit selects both search ( and listing ( in more user-friendly systemwe might want to be more symbolic about that ( check for -search and -list arguments)but bit masks work just as well for this script' scope as usualthis module can also be used interactively the following is one way to determine how many files and directories you have in specific directoriesthe last command walks over your entire drive (after generally noticeable delay!see also the "biggest fileexample at the start of this for issues such as potential repeat visits not handled by this walkerc:\pp \toolspython from visitor import filevisitor filevisitor(trace= run( ' :\temp\pp \examples' dcountv fcount ( run(' dcountv fcount ( independent walk (reset countsv run('reset=falsev dcountv fcount ( accumulative walk (keep countsv filevisitor(trace= run( ' :\\' dcountv fcount ( new independent walker (own countsentire drivetry '/on unix-en although the visitor module is useful by itself for listing and searching treesit was really designed to be extended in the rest of this sectionlet' quickly step through handful of visitor clients which add more specific tree operationsusing normal oo customization techniques editing files in directory trees (visitorafter genericizing tree traversals and searchesit' easy to add automatic file editing in brand-newseparate component example - defines new editvisitor class that simply customizes the visitmatch method of the searchvisitor class to open text editor on the matched file yesthis is the complete program--it needs to do something special only when visiting matched filesand so it needs to provide only that behavior the rest of the traversal and search logic is unchanged and inherited complete system programs