4 ms·
I've seen exceptions masquerading as goto in the wild in multiple python codebases (and not because I added them). `raise HttpResponse(status=401, body="unautho
by emidln 11y ago
I've seen exceptions masquerading as goto in the wild in multiple python codebases (and not because I added them). `raise HttpResponse(status=401, body="unauthorized")` inside some utility method is little more than goto exit in a lot of C code.
- Walkman 11y agoUsing Exceptions this way in Python code is common practice and considered "Pythonic" and it's different than goto: - an Exception only can bubble up the call stack, not to an arbitrary location in the code - it can be caught whatever level during that path