On Tue, Nov 27, 2018 at 10:47:06PM -0600, Abe Dillon wrote: > If we could figure out a cleaner syntax for defining invariants, > preconditions, and postconditions we'd be half-way to automated testing > UTOPIA! (ok, maybe I'm being a little over-zealous)
You should look at the state of the art in Design By Contract. In Eiffel, DBC is integrated in the language: https://www.eiffel.com/values/design-by-contract/introduction/ https://www.eiffel.org/doc/eiffel/ET-_Design_by_Contract_%28tm%29%2C_Assertions_and_Exceptions Eiffel uses a rather Pythonic block structure to define invariants. The syntax is not identical to Python's (Eiffel eschews the colons) but it also comes close to executable pseudo-code. trust this syntax requires little explanation: require ... preconditions, tested on function entry do ... body of the function ensure ... postconditions, tested on function exit end There is a similar invariant block for classes. Cobra is a language which intentionally modeled its syntax on Python. It too has contracts integrated with the language: http://cobra-language.com/how-to/DeclareContracts/ http://cobra-language.com/trac/cobra/wiki/Contracts -- Steve _______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/