Programming By Contract for Python

50 views
Skip to first unread message

Thomas Passin

unread,
Feb 26, 2023, 12:06:31 AM2/26/23
to leo-editor
I just learned something new that may be of interest to some devs.  There are a few packages that add Programming By Contract to Python.  In particular, iContract:


If you have not heard of this approach, it was introduced in the Eiffel language in the late 1980s.  From Wikipedia:

"It prescribes that software designers should define formal, precise and verifiable interface specifications for software components, which extend the ordinary definition of abstract data types with preconditionspostconditions and invariants. These specifications are referred to as "contracts", in accordance with a conceptual metaphor with the conditions and obligations of business contracts."

Edward K. Ream

unread,
Feb 26, 2023, 4:26:40 AM2/26/23
to leo-e...@googlegroups.com
On Sat, Feb 25, 2023 at 11:06 PM Thomas Passin <tbp1...@gmail.com> wrote:

Thanks for this link.  The icontract readme contains several additional links.

CrossHair looks nifty. There is a vs-code plugin for it so Leonistas can play with CrossHair now using leoInteg!

Edward

Edward K. Ream

unread,
Feb 26, 2023, 4:36:59 AM2/26/23
to leo-editor
On Sunday, February 26, 2023 at 3:26:40 AM UTC-6 Edward K. Ream wrote:

CrossHair looks nifty.

The in a supported syntax link in CrossHair's readme shows what contracts look like. Intriguing.

Down the rabbit hole we go: Hypothesis looks worth a look.

Edward

David Szent-Györgyi

unread,
Mar 2, 2023, 9:15:20 PM3/2/23
to leo-editor
Down the rabbit hole we go: Hypothesis looks worth a look.

I know that some time back, I posted a message with links on Hypothesis and Pydantic. I haven't had time to explore them. In case the links are of use in the current dive down the rabbit hole:
Tools of Interest: Hypothesis and Pydantic for Property-based Testing  
Reply all
Reply to author
Forward
0 new messages