If you absolutely want to raise
in an expression, you could do
def raiser(ex): raise ex
return <value> if <bool> else raiser(<exception>)
This "tries" to return the return value of raiser()
, which would be None
, if there was no unconditional raise
in the function.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…