[Tutor] writing & reading files
alan.gauld@bt.com
alan.gauld@bt.com
Thu, 17 Jan 2002 16:25:59 -0000
Frank,
First comment:
Save a lo of typing and lines by putting the
prompt inside the raw_input() call:
> def add_name():
> print 'Enter Name:'
> dname=raw_input()
dname = raw_input('Enter name:\n')
> l=(dname, fname, hnum, ph, pg, cop, com)
> d1[dname]=l
Where is d1 defined?
If you read it in from the pickle file somewhere
else then we're OK, otherwise what? where?
> f=open('phoneyold','w')
> pickle.dump(d1,f)
> f.close()
> d1={}
Ah here it is. But how is it loaded?
I think you need to assign p_d1 to it in your get_name function?
Otherwise the old names are never in d1 and so never
get written out...
Alan g