I Op wo 29 aug. 2018 07:53 schreef Greg Ewing <greg.ew...@canterbury.ac.nz>:
> Wes Turner wrote: > > I'm going to re-write that in a pseudo-Eiffel like syntax: > > Maybe some magic could be done to make this work: > > def __init__(self, img: np.ndarray, x: int, y: int, width: int, > height: int) -> None: > > def __require__(): > x >= 0 > y >= 0 > width >= 0 > height >= 0 > x + width <= pqry.opencv.width_of(img) > y + height <= pqry.opencv.height_of(img) > > def __ensure__(): > (self.x, self.y) in self > (self.x + self.width - 1, self.y + self.height - 1) in self > (self.x + self.width, self.y + self.height) not in self > > # body of __init__ goes here... > I have often wished we could get at the AST of a function object. Then we could inspect the AST and extract these magic functions. Stephan -- > Greg > _______________________________________________ > Python-ideas mailing list > Python-ideas@python.org > https://mail.python.org/mailman/listinfo/python-ideas > Code of Conduct: http://python.org/psf/codeofconduct/ >
_______________________________________________ Python-ideas mailing list Python-ideas@python.org https://mail.python.org/mailman/listinfo/python-ideas Code of Conduct: http://python.org/psf/codeofconduct/