Contracts for Python

Discussion in 'Python' started by Paulo J. Matos, Oct 28, 2008.

  1. 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
     
    Paulo J. Matos, Oct 28, 2008
    #1
    1. Advertising

  2. Paulo J. Matos

    alex23 Guest

    On Oct 29, 3:47 am, "Paulo J. Matos" <> 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"
     
    alex23, Oct 29, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. infoTEAM, inc.
    Replies:
    2
    Views:
    563
  2. Roel Korsten

    Example of end user agreements/contracts

    Roel Korsten, Feb 9, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    363
    Roel Korsten
    Feb 9, 2005
  3. Mike
    Replies:
    8
    Views:
    410
    A Bag Of Memes
    Jul 20, 2003
  4. Rodney Gomes

    new python contracts library

    Rodney Gomes, Jul 12, 2011, in forum: Python
    Replies:
    0
    Views:
    195
    Rodney Gomes
    Jul 12, 2011
  5. Replies:
    5
    Views:
    178
    Mark Janssen
    Feb 15, 2013
Loading...

Share This Page