TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why you should never use 'assert' in Python

2 pointsby albi_landerover 6 years ago

1 comment

ElBartoover 6 years ago
It&#x27;s nothing to do with Python, really.<p>&#x27;assert&#x27; really is a debugging tool that forces an exception and&#x2F;or a core dump on a bug condition.<p>It is standard practice to have assertions in debug builds removed in release builds.<p>Code should not use assertions to detect error cases but only bugs (i.e. conditions which should never be true whatever happens).<p>In the code discussed here they are using &#x27;assert&#x27; to check a password, which is simply bad design.<p>It&#x27;s perfectly fine to use &#x27;assert&#x27; in Python for what it is for.