3 ms·
> That's twice the code for the same result. Only if you ignore that the exception-throwing solution _needs_ comments like `# this might throw a 404` to unders
by yccs27 4y ago
> That's twice the code for the same result.
Only if you ignore that the exception-throwing solution _needs_ comments like `# this might throw a 404` to understand the control flow. The early-return solution is what I'd call self-documenting code.
- kstrauser 4y agoNo more than you'd need comments like `# this might actually return None`. As long as you're consistent, either approach should be understandable by the people working with it. Note that you can also name functions like `validate_signature_or_raise` if you want to be very explicit.