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...

--
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/

Reply via email to