I'm an idiot

Fredrik Lundh fredrik at pythonware.com
Sat Jun 29 08:06:24 EDT 2002


Joseph A Knapka wrote:

> Now, personally, I'd like to have any read after EOF throw
> an exception.

I suggest subclassing the file object, using your custom
subclass for a while, and throwing it out when you get
bored adding all those extra try/except clauses around
your code...

> But I'm sure there are Very Good Reasons not to do this,
> and that some wise person will presently educate me :-)

To many people, this is a religous topic.  Google can probably
tell you all about the different religions.

The most common view is that as the name implies, exceptions
should be used to deal with exceptional, unexpected conditions.
That you'll reach the end of a file if you keep reading data from
it should hardly come as a surprise...

</F>





More information about the Python-list mailing list