4 ms·
Python shouldn't need special lib to design by contract, `assert cond, "reason"` and `if __debug__` work very well for that. Unfortunately, people don't know t
by BiteCode_dev 2y ago
Python shouldn't need special lib to design by contract, `assert cond, "reason"` and `if __debug__` work very well for that.
Unfortunately, people don't know they are made to be stripped in prod with `-OO` so that the perf hit is zero. This means you can never be sure a 3rd party lib you depend on is not using an assert somewhere for a very important check you are going to disable.
https://www.bitecode.dev/p/the-best-python-feature-you-cannot https://www.bitecode.dev/p/the-best-python-feature-you-canno...
- otteromkram 2y agoMore from the official docs: https://docs.python.org/3/reference/simple_stmts.html#index-18 https://docs.python.org/3/reference/simple_stmts.html#index-...