Design By Contract in Python

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Ryan Freckleton

    #1

    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

  • Aaron Brady

    #2
    Re: Design By Contract in Python

    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

    Comment

    Working...