Who needs exceptions

Michael Ströder michael at stroeder.com
Wed Jan 2 12:01:19 EST 2002


Oleg Broytmann wrote:
> 
> On Sat, Dec 29, 2001 at 04:16:03PM +0000, Gerson Kurz wrote:
> > def lower():
> >     file = open(...)
> >     if file:
> >         return file.read()
> >     report_error("lower failed()")
> 
>    That's wrong solution. Imagine I am writing a library (that includes the
> "lower" function). This is  librry, so I cannot define "report_error"
> function.
>    Later you write few different interfaces to the library - web interface,
> text interface (command line), curses, GUI... How can I call different
> report_errors()?
>    Exception handling solves this easily.

Real men (AKA C programmers) use call-back functions (shudder!)...
;-)

Ciao, Michael.



More information about the Python-list mailing list