Op wo 29 aug. 2018 om 03:59 schreef Steven D'Aprano <st...@pearwood.info>:
> On Tue, Aug 28, 2018 at 07:46:02AM +0200, Marko Ristin-Kaufmann wrote: > > Hi, > > To clarify the benefits of the contracts, let me give you an example from > > our code base: > > > > @icontract.pre(lambda x: x >= 0) > > @icontract.pre(lambda y: y >= 0) > > @icontract.pre(lambda width: width >= 0) > > @icontract.pre(lambda height: height >= 0) > > @icontract.pre(lambda x, width, img: x + width <= > pqry.opencv.width_of(img)) > > @icontract.pre(lambda y, height, img: y + height <= > pqry.opencv.height_of(img)) > > @icontract.post(lambda self: (self.x, self.y) in self) > > @icontract.post(lambda self: (self.x + self.width - 1, self.y + > > self.height - 1) in self) > > @icontract.post(lambda self: (self.x + self.width, self.y + > > self.height) not in self) > > def __init__(self, img: np.ndarray, x: int, y: int, width: int, > > height: int) -> None: > > > Thanks for your example Marko. I think that is quite close to the > ugliest piece of Python code I've ever seen, and I don't mean that as a > criticism of you for writing it or the icontract library's design. > > What, really ? Well, it clearly shows you teach python and don't look much at code written by people who taught themselves. I taught myself, and the first .py file I created was over a 1000 lines, and contained the GUI in a 4-deep nested global dictionary, since I'd never seen a style guide at that point. (I got better)
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/