Pop return from stack?

Gregory Ewing greg.ewing at canterbury.ac.nz
Fri Aug 20 21:41:10 EDT 2010


bvdp wrote:

> The whole problem I was having is that I was trying to tie a small
> application (an helper to the main application) to use a bit of the
> existing code as a pseudo-library.

This is precisely the reason that it's a bad idea to
directly terminate the program from somewhere deep inside
the code. It makes it hard to re-use the code in another
context.

It's much better to raise an exception containing an
appropriate error message, catch it at the top level
of the application and print the message and exit there.
Then you can easily re-use any of the code in a context
where it's not appropriate to have it exit out from
under you.


-- 
Greg



More information about the Python-list mailing list