
Aug. 27, 2005
4:04 p.m.
For reading bytes, I *know* that a lot of code would become uglier if the API changed to raise EOFError exceptions
I had StopIteration in mind. Instead of writing: while 1: block = f.read(20) if line == '': break . . . We would use: for block in f.readblocks(20): . . . More beauty, a little faster, more concise, and less error-prone. Of course, there are likely better choices for the method name, but you get the gist of it.