在python中有什么方法可以做任何像
这样的事情X = max_board_X
Y = max_board_Y
neighbors = lambda x, y : [(x2, y2) for x2 in range(x-1, x+2)
for y2 in range(y-1, y+2)
if (-1 < x <= X and
-1 < y <= Y and
(x != x2 or y != y2) and
(0 <= x2 <= X) and
(0 <= y2 <= Y))]
其中var2和var3之间的任何变量也在var1和var4之间会触发if? 我可能会遗漏一些明显的东西,但提前感谢