directory specificationc:\pp \toolsfind py [qx]py :\temp\pp :\temp\pp \examples\pp \database\sqlscripts\querydb py :\temp\pp \examples\pp \gui\tools\queuetest-gui-class py :\temp\pp \examples\pp \gui\tools\queuetest-gui py :\temp\pp \examples\pp \gui\tour\quitter py :\temp\pp \examples\pp \internet\other\grail\question py :\temp\pp \examples\pp \internet\other\xml\xmlrpc py :\temp\pp \examples\pp \system\threads\queuetest py and here' some python code that does the same find but also extracts base names and file sizes for each file foundc:\pp \toolspython import os from find import find for name in find('[qx]py' ' :\temp\pp ')print(os path basename(name)os path getsize(name)querydb py queuetest-gui-class py queuetest-gui py quitter py question py xmlrpc py queuetest py the fnmatch module to achieve such code economythe find module calls os walk to walk the tree and simply yields matching filenames along the way new herethoughis the fnmatch module--yet another python standard library module that performs unix-like pattern matching against filenames this module supports common operators in name pattern stringsto match any number of charactersto match any single characterand and [to match any character inside the bracket pairs or notother characters match themselves unlike the re modulefnmatch supports only common unix shell matching operatorsnot full-blown regular expression patternswe'll see why this distinction matters in interestinglypython' glob glob function also uses the fnmatch module to match namesit combines os listdir and fnmatch to match in directories in much the same way our find find combines os walk and fnmatch to match in trees (though os walk ultimately uses os listdir as wellone ramification of all this is that you can pass byte strings for both pattern and start-directory to find find if you need to suppress unicode filename decodingjust as you can for os walk and glob globyou'll receive byte strings for filenames in the result see for more details on unicode filenames searching directory trees