[Edu-sig] Re: What do files and exceptions have in common?
kent37 at tds.net
Mon Nov 8 02:37:45 CET 2004
Scott David Daniels wrote:
> Kent Johnson wrote:
>> what do files and
>> exceptions have to do with each other, pedagogically?
> I suspect the reason is that coping with files brings unavoidable
> errors in from the environment.
Good point. As soon as you start reading files, you open yourself up to
the viccisitudes of real world data. In fact, a fairly common error on
the Tutor list is an IndexError coming from programs like this:
for line in open(...):
data = line.split()
# do something with data, data, data
when the input file contains a blank line. Sounds like a great way to
More information about the Edu-sig