ANN: Design By Contract for Python 1.0 beta 2
Fri, 6 Jun 2003 16:03:44 -0400
Announcing Design By Contract for Python 1.0 beta 2
(Changes since last announcement at end of this email)
Design by Contract is familiar to anyone who has spent time with the
Eiffel programming language. This implementation is a cross between
full Eiffel-style contracts and the doctest module.
Contracts are high-level assertions that are part of the program's
documentation. Modules and classes have invariants, expressions that
must be true at the start and end of every public function or method
call. Methods and functions have pre-conditions, expressions that must
be true on entry; and post-conditions, expressions that must be true
This version supports the full contract feature set:
* pre: expressions in function and method docstrings;
* post: expressions in function and method docstrings;
* inv: expressions in class and module docstrings;
* post: expressions can access __old__ values and the __return__
* pre: expressions are weakened by derived methods; and
* post: and inv: expressions are tightened by derived classes.
Version 1.0 beta 2 - 06 June 2003
* Use separate exception classes eg PreconditionViolationError
instead of AssertionError
* Correctly weaken pre-conditions: they are not ORed; instead, if
a method fails its precondition and an overridden method's pre-
conditions are still valid, raise an InvalidPreconditionError.
* Support Re-Structured Text (ReST) by allowing :: after pre, post,
* Invariants aren't checked after constructor throws exception
* Only scan for code objects actually defined in specified module,
not just all objects in module namespace
* Save docstring line numbers, useful when raising exceptions to tell
where in the code the exception actually came from.
<P><A HREF="http://www.wayforward.net/pycontract/">Contract 1.0
Design By Contract for Python. (06-Jun-03)