The
pycontract
module provides a really nice way to include invariant,
preconditional, and postconditional contract in python. You can
put your tests in your documentation, so you can easily turn off
contract checking (the module examines the docstrings of your
module). If you use doctest for testing, you can almost
everything to your documentation. It is pretty sweet. It even
works as
reStructuredText.
The only real problem is that it is horribly documented. I really
only learned how to fully use it by reading the source of the
module to see how the author did it. I decided to clean it up a
bit and provide some basic documentation so more people can use
this module.
API Documentation
Downloads
Copyright
the pycontract module is
under the copyright of Terence Way. It is under the LGPL, PSF
License, and the Artistic License. This documentation was created
by Karl Norby; it is in no way officially connected to the main
pycontract module, nor is it endorsed (or denounced). Consider it
under the BSD license and the PSF License.