now that we also know about find operationswriting scripts based upon them is almost trivial when we just need to match filenames example - for instancefalls back on spawning shell find commands if you have them example - pp \tools\cleanpyc-find-shell py ""find and delete all "pycbytecode files at and below the directory named on the command-lineassumes nonportable unix-like find command ""import ossys rundir sys argv[ if sys platform[: ='win'findcmd ' :\cygwin\bin\find % -name "pyc-printrundir elsefindcmd 'find % -name "pyc-printrundir print(findcmdcount for fileline in os popen(findcmd)count + print(filelineend=''os remove(fileline rstrip()for all result lines have \ at the end print('removed % pyc filescountwhen runfiles returned by the shell command are removedc:\pp \toolscleanpyc-find-shell py :\cygwin\bin\find -name "pyc-print /find pyc /visitor pyc /__init__ pyc removed pyc files this script uses os popen to collect the output of cygwin find program installed on one of my windows computersor else the standard find tool on the linux side it' also completely nonportable to windows machines that don' have the unix-like find program installedand that includes other computers of my own (not to mention those throughout most of the world at largeas we've seenspawning shell commands also incurs performance penalties for starting new program we can do much better on the portability and performance fronts and still retain code simplicityby applying the find tool we wrote in python in the prior section the new script is shown in example - example - pp \tools\cleanpyc-find-py py ""find and delete all "pycbytecode files at and below the directory named on the command-linethis uses python-coded find utilityand complete system programs