Programming by Contract in Python
23rd May 2003
Programming by Contract seems to be a sister technique to unit testing—instead of (or as well as) writing a set of tests for a piece of code you write a set of pre- and post-conditions for the data being processed which are then checked whenever the program is run in debugging mode. Contracts for Python discusses the technique, providing a reference implementation and a PEP suggesting inclusion of support for the technique in the core language. Programming by contract was first demonstrated in the Eiffel language, and there’s a good introduction to it in Eiffel.com as well.
More recent articles
- Fly's new Sprites.dev addresses both developer sandboxes and API sandboxes at the same time - 9th January 2026
- LLM predictions for 2026, shared with Oxide and Friends - 8th January 2026
- Introducing gisthost.github.io - 1st January 2026