[Python-ideas] Simplicity of C (was why is design-by-contracts not widely)
elazarg at gmail.com
Sun Sep 30 08:32:16 EDT 2018
On Sun, Sep 30, 2018, 15:12 Stephen J. Turnbull <
turnbull.stephen.fw at u.tsukuba.ac.jp> wrote:
> Steven D'Aprano writes:
> > (4) Inheritance
> > Contracts are inherited, unit tests are not.
> What does "inherited" mean? Just that methods that are not overridden
> retain their contracts?
Contracts are attached to interfaces, not to specifications. So when you
have abstract base class, it defines contracts, and implementing classes
must adhere to these contracts - the can only strengthen it, not weaken it.
This way the user code need pnly be aware of the specification, not the
So method that _are_ overridden retain their contracts.
This is precisely like with types, since types are contracts (and vice
versa, in a way).
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas