473,406 Members | 2,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Design By Contract in Python

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
1 2136
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

36
by: Andrea Griffini | last post by:
I did it. I proposed python as the main language for our next CAD/CAM software because I think that it has all the potential needed for it. I'm not sure yet if the decision will get through, but...
4
by: emma middlebrook | last post by:
Hi Straight to the point - I don't understand why System.Array derives from IList (given the methods/properties actually on IList). When designing an interface you specify a contract. Deriving...
10
by: cody | last post by:
Hi! I have a class Customer which contains Contacts in a ContactsCollection. class Customer { ... public ContactsCollection Contacts {
10
by: antheana | last post by:
Hi there, I am currently redesigning a database, which includes a contracts table that captures information about each contract e.g. ContractID (PK) ContractReference ContractTypeID (FK) ...
4
by: S. Allsopp | last post by:
I have a design question concerning duplicating tables. I have a table of contract info and each contract can have expeditures, tasking, documentation and deliverables. Each of these items are in...
0
by: AMDRIT | last post by:
I am looking for better concrete examples, as I am a bit dense, on design patterns that facilitate my goals. I have been out to the code project, planet source code, and microsoft's patterns and...
29
by: Brad Pears | last post by:
Here is a simple OO design question... I have a Contract class. The user can either save an existing contract or they start off fresh with a blank contract, fill in the data and then save a...
81
by: Russ | last post by:
I just stumbled onto PEP 316: Programming by Contract for Python (http://www.python.org/dev/peps/pep-0316/). This would be a great addition to Python, but I see that it was submitted way back in...
9
by: Andy B | last post by:
I need to decide on how to store online signed contracts for customers and clients. I have considered a database in sql server 2005, but it seems to be too complicated. Besides, if the contract...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.