By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,011 Members | 1,001 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,011 IT Pros & Developers. It's quick & easy.

Design By Contract in Python

P: n/a
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

Nov 18 '08 #1
Share this Question
Share on Google+
1 Reply


P: n/a
On Nov 18, 12:22*am, Ryan Freckleton <ryan...@cerris.comwrote:
Any and all constructive critiques are be welcome

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

Thanks,
Ryan Freckleton
The links produced the following error message:

/home/pastebin/public_html/../posts/ needs to be a writable dir to use
file storage engine

Nov 18 '08 #2

This discussion thread is closed

Replies have been disabled for this discussion.