[Tutor] Eek, help!
cyresse at gmail.com
Thu Nov 4 14:25:38 CET 2004
I have belatedly come to use dictionaries, and I was having some
trouble with how to read/write them from a file, so I looked at Alan
Gauld's section on it. I've pretty much copied his code straight
through, and, well, I've broken it somehow. In fact, it's hanging
Python, and it even hangs the debugger, which is a first, I must
The errant code as follows is -
filename = './dat/hshmd5.tbl'
store = file(filename,'w')
for name, entry in h.items():
store.write(name + '\n')
store.write(entry + '\n')
print 'Wrote hash'
store2 = file(filename,'r')
name = store2.readline().strip()
entry = store2.readline().strip()
book[name] = entry
It writes OK, it gets up to anyKey bit and... stops. Anything jump out
at anyone? I am confused.
Thanking you in advance,
'There is only one basic human right, and that is to do as you damn well please.
And with it comes the only basic human duty, to take the consequences.
More information about the Tutor