raise statement on a conditional expression
raise statement on a conditional expression Question: How do I elegantly implement the "Samurai principle" (return victorious, or not at all) on my functions? return <value> if <bool> else raise <exception> Asked By: F.D.F. || Source Answers: Well, you could test for the bool separately: if expr: raise exception(‘foo’) return val That way, you could …