Books Database

Eliran Gonen eg at rootshell.be
Fri Mar 7 08:09:46 EST 2003


Alex Martelli <aleaxit at yahoo.com>: 
>     thefile = open('X','r+')
>     lines = thefile.readlines()
>     del lines[X]
>     thefile.seek(0)
>     thefile.writelines(lines)
>     thefile.close()

The code is:

infile = open(database, 'r+')
lines = infile.readlines()
del lines[0]
infile.seek(0)
infile.writelines(lines)
infile.close()

Now the database is like that :

sample|none|1924|nobody
stuff|two|1934|tree

Now executing the above code results in:

stuff|two|1934|tree
ody
stuff|two|1934|tree

Bizarre.





More information about the Python-list mailing list