Skip to content

Ceasar/pyDbC

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Inspired by Eiffel's Design by Contract, this module lets Python developers
write effective contracts for class methods.

FEATURES
-Ability to disable contracts when shipping code, (similar to disabling
asserts) by running the interpreter with -O (optimization) option.
-'old' and 'result' constructs in postcondition, via self.old and self.result
-Extremely light-weight. Only need to copy contract.py to get started.
-All the benefits of contracts.

To use, simply copy contract.py and subclass Contract to specify contract
for each method. Define 'require' and 'ensure' as needed and then decorate the
associated method with the contract to enforce it.

Importantly, Contracts, like assertions, can be turned off by running the
interpreter in optimization mode, via appending the option -O.

See the stack example here to get a sense for how organizing a project
with contracts works.

About

Design by Contract for Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages