Exception style (was: calling python functions using variables)

Carl Banks invalidemail at aerojockey.com
Sat May 20 10:52:28 CEST 2006

Dennis Lee Bieber wrote:
> On Fri, 19 May 2006 14:41:13 +0000, claird at lairds.us (Cameron Laird)
> declaimed the following in comp.lang.python:		.
> > Guys, I try--I try *hard*--to accept the BetterToAskForgiveness
> > gospel, but this situation illustrates the discomfort I consistently
> > feel:  how do I know that the NameError means VARIABLE didn't resolve,
> > rather than that it did, but that evaluation of commands.VARIABLE()
> 	I'd suggest that each of your "valid" commands should contain
> whatever error checking is appropriate to it -- and if needed, raise
> some custom "command failure" exception after handling the real failure
> internally.

That probably doesn't help when the exception is due to a bug and not
bad input.  If you have an AttributeError due to a bug, it would be
wrong to raise a custom command failure exception.

Carl Banks

More information about the Python-list mailing list