> done=0
> fd = open("draw__output.txt",'r')
> while not done:
> line = fd.readline()
> if line == '':
> done = 1
> else:
> for i in line:
> d[i] = int(d[i])+ 1
Code simplification: you can do a loop directly across files. Files
provide an "iterator" that allow us to march line by line across it. The
above code can be transformed into:
#################################
fd = open("draw__output.txt",'r')
for line in fd:
for i in line:
d[i] = int(d[i])+ 1
#################################
For more information about iterators, see:
http://www.python.org/dev/peps/pep-0234/
In particular, skip down to the Dictionary Iterators and File Iterators
sections: they should help show how to use the standard iterators types in
Python.
Good luck!
_______________________________________________
Tutor maillist - [email protected]
http://mail.python.org/mailman/listinfo/tutor