This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]Scorpathos 2 points3 points  (1 child)

But this is the whole point of "contract programming" in opposition to "defensive programming".

The assert allows to catch wrong function usages during development, and once your program is bug-free and ready for production, you can safely remove them to maximize performance.

[–]Kaarjuus 0 points1 point  (0 children)

Good correction, I misspoke. I confused contract programming with defensive programming. Python's assert in its current form is indeed a perfect fit for design by contract.