Design By Contract in Python

R

Ryan Freckleton

Hi Everyone,

I'm currently developing a decorator and metaclass based implementation
of design by contract for python. (I'd have uploaded it to PyPI already,
but I haven't had time to create a GPG key) and wanted to see if anyone
wanted to take a look or interested in trying it out.

Basically design by contract is a way of verifying expectations about
object state and method use at runtime. There are a few python packages
that already exist and attempt to do this, but they have some problems
with implementation (they would fail on the example given below) or API
(they put expectations in docstrings) that I don't agree with.

I haven't tried this out with diamond (or multiple) inheritance, and
there are still a few features missing. But it should be pretty rock
solid besides those points.

Any and all constructive critiques are be welcome

Implementation: http://pastebin.com/f368d5396
Example class: http://pastebin.com/f51be54be


Thanks,
Ryan Freckleton
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,584
Members
45,075
Latest member
MakersCBDBloodSupport

Latest Threads

Top