[Python-ideas] Pre-conditions and post-conditions
Marko Ristin-Kaufmann
marko.ristin at gmail.com
Fri Aug 31 00:05:28 EDT 2018
Hi Ethan,
You are right, I deleted it without noticing.
It should say: pre(len(lst) < 10).
Le jeu. 30 août 2018 à 23:02, Ethan Furman <ethan at stoneleaf.us> a écrit :
> On 08/30/2018 01:49 PM, Marko Ristin-Kaufmann wrote:
>
> > classC(A):
> > # C.some_func also inherits the contracts from A.
> > # It weakens the precondition:
> > # it operates either on sorted lists OR
> > # the lists that are shorter than 10 elements.
> > #
> > # It strenghthens the postcondition:
> > # It needs to return an integer larger than
> > # the length of the input list AND
> > # the result needs to be divisible by 2.
> > @icontract.post(lambdaresult: result %2==0)
> > defsome_func(self, lst: List[int]) ->int:
> > # ...
>
> I think you forgot an @icontract.pre() here.
>
> --
> ~Ethan~
> _______________________________________________
> Python-ideas mailing list
> Python-ideas at python.org
> https://mail.python.org/mailman/listinfo/python-ideas
> Code of Conduct: http://python.org/psf/codeofconduct/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20180831/c93424db/attachment-0001.html>
More information about the Python-ideas
mailing list