YAS to the "Reading line-by-line" Problem

William Tanksley wtanksle at dolphin.openprojects.net
Tue Jun 22 21:02:45 EDT 1999


On Tue, 22 Jun 1999 15:09:36 -0400, Jesse D. Sightler wrote:
>Ack is raising an exception for a normally occuring event really a
>_good_ idea?  Generally exceptions are only used for things that
>actually are error conditions, and it would seem to me that using them
>as nothing more than a fancy flow-control construct is a sure path to
>nasty spaghetti code.

Exceptions may be used for errors, but they're actually intended for
_exceptions_ to normal operation.

Normal operation for a function named "readline" is to return the next
char in the file and advance the file pointer.  There are two exceptions
to this behavior: when the file pointer is invalid, and when it can't be
advanced.  Both should be handled by exception, not by returning a special
value.

-- 
-William "Billy" Tanksley
Utinam logica falsa tuam philosophiam totam suffodiant!
   :-: May faulty logic undermine your entire philosophy!




More information about the Python-list mailing list