[Tutor] associating two objects without ORM and processing a text file
neubyr at gmail.com
Wed Feb 13 20:14:17 CET 2013
On Tue, Feb 12, 2013 at 4:56 PM, Steven D'Aprano <steve at pearwood.info>wrote:
> On 13/02/13 04:32, neubyr wrote:
> I am not following your comment on opening books file twice in
>> list_by_author method. I have opened it only once and then reading each
>> line while checking for a regex match. Am I missing something?
> You open the catalog file once to read the books in the first place.
> Then when you want a list of books by author Fred, you open the catalog
> file, even though all the books are (somewhere) in memory.
> Then when you want a list of books by author Bob, you open the catalog
> file again. Then when you want a list of books by Sally, you open the
> catalog file yet again. And so on.
Thank you for your feedback Dave and Steven.
I realize that I am opening the file for every add/delete call. I thought
you were referring to duplicate file open call within the code snippet
I am not sure how to save an object in memory to a file before exiting the
program. Any examples or related documentation links would be really
helpful. I am guessing it would be using some kind of before teardown
method, but not sure about it. Any help?
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Tutor