here is my code :
Code:
dbfilename = 'people-file'
ENDDB = 'enddb.'
ENDREC = 'endrec.'
RECSEP = '=>'
def storeDbase(db, dbfilename=dbfilename):
dbfile = open(dbfilename, 'w')
for key in db:
print(key, file=dbfile)
for(name,value) in db[key].items():
print(name + RECSEP + repr(value), file=dbfile)
print(ENDREC, file=dbfile)
dbfile.close()
When I try to run this snippet of code I get the traceback that there is an I/O error : Trying to write to closed file????!?!?!?! The lines in bold show where the file is opened, and the last line of bold is where the exception is generated. Any ideas?
Bookmarks