On Thu, 2 Aug 2001, Eric S. Raymond wrote: > No. The existing code in the fileinput module is intended to treat a > sequence of files as one continuous input source. My module is > designed to iterate over files, transforming each one to a > corresponsing named output file. I did a FileUtil module for MacPython -- perhaps it was more complicated because it did all of the GUI also -- progress dialog with info lines and a cancel button, message boxes on errors, etc. You could drop a folder full of files on it and it would iterate thru them. But I found it difficult to generalize sufficiently -- there was not only different file processing methods to be defined, there were different input/output filename transformation rules, different message templates, different file selection rules, etc. Still -- it was useful, but I think I kept fiddling with it almost every time I used it. I think I started with a function that was passed a process callback function. It ended up a class that could be extended for each particular file processing job. But I think if I did it again now, I'ld use some sort of generator. There was some discussion of this: that the os.path.walk way of iterating with callbacks is really inside-out. Nested generators might be a handier building block for this sort of job -- kind of the python equivalent of a unix pipeline command. -- Steve
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4