[Python-ideas] Pre-conditions and post-conditions
Greg Ewing
greg.ewing at canterbury.ac.nz
Wed Aug 29 01:52:46 EDT 2018
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
More information about the Python-ideas
mailing list