[Python-ideas] Pre-conditions and post-conditions
Steven D'Aprano
steve at pearwood.info
Tue Aug 21 06:20:35 EDT 2018
On Tue, Aug 21, 2018 at 09:06:54AM +0200, Marko Ristin-Kaufmann wrote:
> Is there any chance to introduce these constructs in the language or is it
> too small a feature for such a big change?
I don't think contracts is a small feature. I think it is a HUGE
feature, but under-appreciated by most developers. (Probably due to
unfamiliarity, and the difficulty in using it in a language with no
syntactic support.)
Whether it is practical to add it to Python, I don't know. I suspect
that we would have to develop some sort of third-party solution first,
even if it did not do everything contracts ought to do (or do them less
efficiently) as a proof of concept. PyContracts is probably a good place
to start. For those who missed Wes' email:
https://andreacensi.github.io/contracts/
Cobra is another good place to look, as it demonstrates a
nice syntax that reads like a cross between Python and Eiffel:
http://cobra-language.com/trac/cobra/wiki/Contracts
--
Steve
More information about the Python-ideas
mailing list