tree as you can seethe results for largest files differ when viewed by size and lines- disparity which we'll probably have to hash out in our next requirements meeting scanning the entire machine finallyalthough searching trees rooted in the module import path normally includes every python source file you can import on your computerit' still not complete technicallythis approach checks only modulespython source files which are toplevel scripts run directly do not need to be included in the module path moreoverthe module search path may be manually changed by some scripts dynamically at runtime (for exampleby direct sys path updates in scripts that run on web serversto include additional directories that example - won' catch ultimatelyfinding the largest source file on your computer requires searching your entire drive-- feat which our tree searcher in example - almost supportsif we generalize it to accept the root directory name as an argument and add some of the bells and whistles of the path searcher version (we really want to avoid visiting the same directory twice if we're scanning an entire machineand we might as well skip errors and check line-based sizes if we're investing the timeexample - implements such general tree scansoutfitted for the heavier lifting required for scanning drives example - pp \system\filetools\bigext-tree py ""find the largest file of given type in an arbitrary directory tree avoid repeat pathscatch errorsadd tracing and line count size also uses setsfile iterators and generator to avoid loading entire fileand attempts to work around undecodable dir/file name prints ""import ospprint from sys import argvexc_info trace dirnameextname os curdirpyif len(argv dirname argv[ if len(argv extname argv[ if len(argv trace int(argv[ ] =off =dirs =+files default is py files in cwd exc:\ :\python \lib expywtxt expy def tryprint(arg)tryprint(argexcept unicodeencodeerrorprint(arg encode()unprintable filenametry raw byte string visited set(allsizes [for (thisdirsubsherefilesherein os walk(dirname)if tracetryprint(thisdirthisdir os path normpath(thisdir complete system programs