Books Database
Alex Martelli
aleaxit at yahoo.com
Fri Mar 7 09:01:54 EST 2003
More information about the Python-list mailing list
Fri Mar 7 09:01:54 EST 2003
- Previous message (by thread): Books Database
- Next message (by thread): Books Database
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Friday 07 March 2003 02:16 pm, Eliran Gonen wrote: > Alex Martelli <aleaxit at yahoo.com>: > > > books = file('books.dat').readlines() > > > > del books[3] > > > > > file('books.dat', 'w').writelines(books) > > > > > > But the point is that you process everything in memory and then > > > overwrite the file when done rather that trying to manipulate > > > the individual lines of the file directly. > > Would that be more efficient (keep everything in an inside > variable/list/whatever instead of reading the file again > and again) ? Yes, keeping the data in memory throughout each run will be more simple and efficient. You may want to write it out periodically if it's changed, just to make sure it's safe if the computer crashes or something like that. Alex
- Previous message (by thread): Books Database
- Next message (by thread): Books Database
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list