C.<p><span class="h-card" translate="no"><a href="https://hachyderm.io/@graham_knapp" class="u-url mention" rel="nofollow noopener" target="_blank">@<span>graham_knapp</span></a></span> </p><p>A lot of it is always going to come down to personal preferences. But I think the different cases are more or less appropriate depending on the problem being solved.</p><p>If you're calling a function or creating an object that you expect to almost-always work - it fails when low on memory, or when the network connection is broken, or some other exceptional (hint) condition, then I think exceptions are most appropriate. Throw one, and let it bubble up the caller's stack until they either handle it and possibly re-try, or the program exits with a diagnostic.</p><p>If you're calling something that can reasonably be expected to both succeed or fail under normal conditions - say a command given in an inappropriate state fails, but otherwise succeeds, maybe - then an explicit return object with success/failure (and possibly a result, and / or an error message) can be better, as the caller expects to handle failures immediately.</p><p>Both are easy in Python; I've implemented the latter with tuples, named tuples, custom classes, and dataclasses over the years for different projects.</p><p></0.02></p><p><a href="https://mindly.social/tags/software" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>software</span></a> <a href="https://mindly.social/tags/engineering" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>engineering</span></a> <a href="https://mindly.social/tags/SoftwareEngineering" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>SoftwareEngineering</span></a> <a href="https://mindly.social/tags/programming" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>programming</span></a> <a href="https://mindly.social/tags/preference" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>preference</span></a> <a href="https://mindly.social/tags/choice" class="mention hashtag" rel="nofollow noopener" target="_blank">#<span>choice</span></a></p>