[Tutor] associating two objects without ORM and processing a text file
Dave Angel
davea at davea.name
Tue Feb 12 21:58:39 CET 2013
On 02/12/2013 12:32 PM, neubyr wrote:
> On Mon, Feb 11, 2013 at 7:34 PM, Steven D'Aprano <steve at pearwood.info>wrote:
>
>> <snip>
>
> 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?
>
Not tiwce, 490 times. Each time you call that method, you're going to
open and read the whole file? Why on earth would you do that, rather
than just storing the Book instances in a list for later perusal? Read
the file when starting, and save it when quitting. You did say you were
going to be inserting and deleting books, right? You sure don't want to
write that code to manage a text file.
--
DaveA
More information about the Tutor
mailing list