On Tue, Feb 12, 2013 at 4:56 PM, Steven D'Aprano <st...@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
itself.

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?

thanks,
N
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to