pprint pprint(allsizes[- :]when runthis script marches down the module import path andfor each valid directory it containsattempts to search the entire tree rooted there in factit nests loops three deep--for items on the pathdirectories in the item' treeand files in the directory because the module path may contain directories named in arbitrary waysalong the way this script must take care tonormalize directory paths--fixing up slashes and dots to map directories to common form normalize directory name case--converting to lowercase on case-insensitive windowsso that same names match by string equalitybut leaving case unchanged on unixwhere it matters detect repeats to avoid visiting the same directory twice (the same directory might be reached from more than one entry on sys pathskip any file-like item in the tree for which os path getsize fails (by default os walk itself silently ignores things it cannot treat as directoriesboth at the top of and within the treeavoid potential unicode decoding errors in file content by opening files in binary mode in order to count their lines text mode requires decodable contentand some files in python ' library tree cannot be decoded properly on windows catching unicode exceptions with try statement would avoid program exitstoobut might skip candidate files this version also adds line countsthis might add significant run time to this script toobut it' useful metric to report in factthis version uses this value as sort key to report the three largest and smallest files by line counts too--this may differ from results based upon raw file size here' the script in action in python on my windows machinesince these results depend on platforminstalled extensionsand path settingsyour sys path and largest and smallest files may varyc:\pp \system\filetoolsbigpy-path py by size [( ' :\\python \\lib\\build_class py')( ' :\\python \\lib\\email\\mime\\__init__ py')( ' :\\python \\lib\\email\\test\\__init__ py')[( ' :\\python \\lib\\tkinter\\__init__ py')( ' :\\python \\lib\\decimal py')( ' :\\python \\lib\\pydoc_data\\topics py')by lines [( ' :\\python \\lib\\build_class py')( ' :\\python \\lib\\email\\mime\\__init__ py')( ' :\\python \\lib\\email\\test\\__init__ py')[( ' :\\python \\lib\\turtle py')( ' :\\python \\lib\\test\\test_descr py')( ' :\\python \\lib\\decimal py') quick game of "find the biggest python file