Checking for an exception

Ben Finney ben+python at benfinney.id.au
Sat Jun 24 23:47:50 EDT 2017


Steve D'Aprano <steve+python at pearwood.info> writes:

> […] the result of passing a non-exception to raise is to raise an
> exception, so I cannot trivially distinguish between "caller passes an
> exception" and "caller passes a non-exception" (result is still an
> exception).

Yes, hence my characterising this problem as the caller's problem.

I'd say: document the expectation that the value will be an exception,
use it based on that specification, and let the caller deal with the
consequences of violating that expectation.

-- 
 \        “I went to court for a parking ticket; I pleaded insanity. I |
  `\   said ‘Your Honour, who in their right mind parks in the passing |
_o__)                                           lane?’” —Steven Wright |
Ben Finney




More information about the Python-list mailing list