On 25Jun2017 13:47, Ben Finney <ben+pyt...@benfinney.id.au> wrote:
Steve D'Aprano <steve+pyt...@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'm a "fail early" kind of guy, and to me Steve's approach is in the same spirit as raising ValueError when a function is handed invalid arguments.

Particularly if the mistake is easy to make, having one's attention brought to it immediately (at "declaration" time, since Steve's example is a decorator), seems very desirable.

Cheers,
Cameron Simpson <c...@zip.com.au>
--
https://mail.python.org/mailman/listinfo/python-list

Reply via email to