in reply to Discussion(maybe?) How would you do this? Modules and reading a file/dir

As others have said, the "problem" is too vague. But just in case it actually involves handling data files that serve specific, predictable, pre-established functions -- such as "address.list", "invoice.table", "personnel.file", "product.inventory", or stuff like that -- a decent approach would be to create a separate module for each type of data.

Each module knows how to read, modify and save it's own type of data, and when a script uses a module and invokes one of it's methods, the associated data file is read just once, and can be used, updated and saved back to disk as often as you want during the lifetime of any one process.

If there are multiple steps in a given process that use a given type of file, the corresponding module will always have its current state and content already loaded as module-internal data, with appropriate "getters" and "setters" (and other convenience functions as you see fit) tailored to that type of file.

  • Comment on Re: Discussion(maybe?) How would you do this? Modules and reading a file/dir