A design-by-contract Python package in ~100 lines
Greetings! A 2.5 weekends project to teach myself newer Python features (>= 3.10). Conditions are written as Lambda expressions that annotate parameters and return types, and coexist with type annotations. Symbols to share values between conditions are also supported to a limited extend.
A design-by-contract Python package in ~100 lines launched on July 12, 2022 with 58 votes, #706 of 2,916 launches that month and more than 90% of that year's launches. The site was still online in September 2026, 4 years on.
In plain words
This is a lightweight Python package implementing design-by-contract principles, created as a learning project for Python 3.10+ features. Developers can specify preconditions and postconditions using lambda expressions that work alongside standard type annotations, with limited support for sharing values between conditions. The package is compact at approximately 100 lines of code and demonstrates contract-based programming patterns for Python development.
written from the facts on this page · September 2026
From the sources
Handy decorator for elegant design-by-contract in 3.10+ - StefanUlbrich/design-by-contract
Does a similar job
all alternatives →
“Statements and State”, the next chapter of my book on interpreters2017 · craftinginterpreters.com · ▲141
I wrote a book about Python2021 · pragprog.com · ▲181Hey HN! I wrote a book on programming called The Elements of Code. I put the entire book online here: https://elementsofcode.io/ When mentoring (usually new) programmers, I noticed there were a few common mistakes that seemed to account for about 80% of the complexity in their code. I couldn’t find a concise guide to fixing those mistakes, so I decided to write one. The title is an homage to The Elements of Style by Strunk and White, which is the classic guide for communicating well using prose. That guide is quite tactical in nature, and I wanted to parallel its focus in The…
Practical Python Projects book release2021 · practicalpython.yasoob.me · ▲88Hi everyone! I just released the Practical Python Projects book! (https://practicalpython.yasoob.me) I am happy to announce the first version as a release candidate. I have poured a lot of love into writing this book and would love to hear what you guys think. (A limited 100% off and discount coupons at the end) This is not a pure beginner book. The book does assume some background Python knowledge. You need to know the basics like methods, functions, classes, and such. If I use something that is not typically covered in beginner Python books, I will explain it before I use it.…
A Python with Hindley-Milner-like type annotations, compiling to C2015 · github.com · ▲134a python-like language with hindley-milner-like type system, which is compiled to c - alehander92/Airtight
Full Stack Python2016 · fullstackpython.com · ▲78Explains programming language concepts in plain language.
Build optimized Python AWS Lambda layers2020 · github.com · ▲45A build tool for creating optimized Python AWS Lambda layers - tobilg/python-lambda-layer-builder
More dev tools this month
the category →

open-source IDE for thoughtful software design. Contribute to devdotfast/whiteboard development by creating an account on GitHub.
Dev tools · 28d ago · github.com

Contribute to reladraw/reladraw development by creating an account on GitHub.
Dev tools · 26d ago · github.com
OpenBot▲362Grok Bot alternative: free, local, open-source, multiplayer
Dev tools · 23d ago · openbot.run
Talanoa▲346Hi HN, I’m a fullstack developer, and honestly, I’ve lost count of how many side projects I’ve worked on over the years. But one idea kept coming back to me: a different kind of email client. It first came to me in 2014: “What if we could handle emails more like conversations?” Every year, I’d revisit this concept in my “Build Notes.” Ten years later, no one had built exactly what I had in mind — so I finally decided to do it myself. That’s how Talanoa was born. I wanted something focused on people, not timelines. I was tired of marking messages as unread just to remember to reply later, or…
Dev tools · 21d ago · talanoa.email
CoreSpeed▲332One MCP for everything your agents need: apps, memory, tools
Dev tools · 28d ago · corespeed.io
Source: Show HN post ↗
Launched alongside, July 2022
the whole month →
Locofy.ai▲720Hey there, I am Honey - Co-founder at Locofy. We, along with other makers, have been building Locofy.ai to help massively accelerate the builders - the designers, developers, product managers & founders, and we're excited to share it today with the HN Community. Locofy.ai simply converts designs into production-ready frontend code for web and mobile apps. It adapts to your preferred design tools, tech stack, and workflows with ease and lets you launch upto 4x faster, while letting designers design the way they want and giving high-quality responsive code that developers love. With this…
Dev tools · 2022 · locofy.ai
- PO
Life & fun · 2022 · justine.lol

Open Source realtime backend in 1 file. Contribute to pocketbase/pocketbase development by creating an account on GitHub.
Dev tools · 2022 · github.com
ruttl▲552Visual & Design Feedback Tool that helps you review design, content and report bugs on websites, applications, PDFs and images.
Dev tools · 2022 · ruttl.com

Hello, HN - I wanted to share this puzzle game I made during my vacation. I'm rather fond of the pipes puzzle where your goal is to restore a scrambled network of connections by rotating tiles. It's usually played on a grid of squares and this all started when I decided to make a programmatic solver for that kind of puzzle. Then I realized that with some minor changes the solver could generate new puzzle instances. I thought about what kind of puzzle to make and someone suggested a hexagonal grid. Adapting the generator wasn't too hard but then I had to create a way to play this variant. So…
Life & fun · 2022 · hexapipes.vercel.app

We're building Parsnip to create a "tech tree" of cooking skills that allows anyone to level up on the building blocks of cooking knowledge while tracking their progress over time. It took us a few iterations to figure out the right product; here's the story of our latest pivot: [https://parsnip.substack.com/p/a-new-hope] The goal is to create a personalized way to learn any recipe on the Internet, then use this as a springboard to help home cooks of all levels solve the problem of repeated meal planning in a 10x better way:…
Work · 2022 · parsnip.ai