Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Contracts for Python

Reply
Thread Tools

Contracts for Python

 
 
Paulo J. Matos
Guest
Posts: n/a
 
      10-28-2008
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
 
Reply With Quote
 
 
 
 
alex23
Guest
Posts: n/a
 
      10-29-2008
On Oct 29, 3:47*am, "Paulo J. Matos" <(E-Mail Removed)> wrote:
> 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"
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
any chance for contracts and invariants in Python? mrkafk@gmail.com Python 5 02-15-2013 02:33 AM
new python contracts library Rodney Gomes Python 0 07-12-2011 05:59 PM
managing cisco contracts with SCC end user too Cisco 0 01-28-2004 12:23 AM
JOB: Houston, TX >> Web / .NET Developers (6 months+ contracts) infoTEAM, inc. ASP .Net 2 12-27-2003 05:49 AM
IOS Licensing / SmartNet Contracts Fatman Superstar Cisco 8 11-16-2003 04:29 AM



Advertisments