, "" , . "args". "-r", . os.walk() .. , , , .
If a program works with a list of paths, it is very easy to use it in different ways. For example, you can list one data file for testing. To process the directory, run "myprogram dir / *. Dat". To process the file tree, use backticks:
myprogram `find . -name "*.dat"`
Finally, you can do very cheap parallel processing. Sort of:
find . -name '*.dat' | xargs -P 5 myprogram
Five copies of your program run in parallel. No locking or plugs or threads or other timing is required.
(The above assumes you are on a system such as Linux / OSX.)
source
share