On Mon, 27 Aug 2018 at 11:39, Steven D'Aprano <st...@pearwood.info> wrote:
> On Mon, Aug 27, 2018 at 09:24:20AM +0100, Ivan Levkivskyi wrote: > > TBH, I think one of the main points of design by contract is that > contracts > > are verified statically. > > No, that's not correct. Contracts may be verified statically if the > compiler is able to do so, but they are considered runtime checks. > Considered by whom? By people who prefer `assert isinstance(x, int)` over `x: int`? :-) Contract in 99% of cases is just another word for type (maybe a very complex type like `DAG[T] <: Graph[T]`). Everything else, like `x >= y` is better expressed as an explicit assert with an assert message. But again this is rather IMO, than any kind of definition. There is only one use case I see now where a dedicated syntax would give a large readability gain: something like `self.x >= self.y`. But on the other hand I think such situations are too rare to justify any _new_ syntax. -- Ivan
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/