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

Contracts for Python

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.