473,399 Members | 2,478 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,399 software developers and data experts.

Contracts for Python

Hi all,

I am wondering if there is any work on contracts for Python. I could
only find PEP316, however, I am wondering if there is any official
support for it already (tools I mean), and if it is or if it will be
officially supported in any of the next releases of Python.

Cheers,
--
Paulo Jorge Matos - pocmatos at gmail.com
Webpage: http://www.personal.soton.ac.uk/pocm
Oct 28 '08 #1
1 1022
On Oct 29, 3:47*am, "Paulo J. Matos" <pocma...@gmail.comwrote:
I am wondering if there is any work on contracts for Python. I could
only find PEP316, however, I am wondering if there is any official
support for it already (tools I mean), and if it is or if it will be
officially supported in any of the next releases of Python.
It's possible to get a simplistic design-by-contract approach without
external libs by using 'assert'.

Here's a modified example from PEP 316:

class circbuf:

def __init__(self, leng):
"""Construct an empty circular buffer."""

# pre
assert leng 0, "pre: length not positive"

...

# post
assert self.is_empty(), "post: buffer not empty"
assert len(self.buf) == leng, "post: buffer length incorrect"
Oct 29 '08 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: pratham | last post by:
Hi, I was seeing code of PetShop 2.0 and find is quite .. differnet design and architecture .. too much of clutter in classes .. order class using and Iorder and Iorder using an orderInfo and...
4
by: Kosmos | last post by:
Hey guys...as a relatively new programmer, I try to give back where I can. Below is the code for a useful program I believe many of you could use...just don't use the same exact code because...well I...
1
by: Nospam | last post by:
I am trying to have an expandable menu each time it's clicked expands, and if it's clicked again, if it is already expanded contracts, and if contracted expands, following this example...
0
by: Chris Rebert | last post by:
On Tue, Oct 28, 2008 at 10:47 AM, Paulo J. Matos <pocmatos@gmail.comwrote: No, it's not officially supported and there are currently no plans to support it, though as PEP 316 is Deferred and not...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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
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.